public function onPostSerialize(ObjectEvent $event)
    {
        // getSubscribedEvents doesn't seem to support parent classes
        if (!$event->getObject() instanceof MediaInterface) {
            return;
        }

        /** @var MediaInterface $media */
        $media = $event->getObject();

        $provider = $this->getProvider($media);

        if ($provider->getName() == 'image') {
            $images = $this->getImages($media, ['medialibrary']);

            $event->getVisitor()->addData('images', $images);
        }

        $event->getVisitor()->addData('original', $provider->getUrl($media));
    }
public function onPostSerialize(ObjectEvent $event)
    {
        // getSubscribedEvents doesn't seem to support parent classes
        if (!$event->getObject() instanceof MediaInterface) {
            return;
        }

        /** @var MediaInterface $media */
        $media = $event->getObject();

        $provider = $this->getProvider($media);

        if ($provider->getName() == 'image') {
            $images = $this->getImages($media, ['medialibrary']);

            $event->getVisitor()->addData('images', $images);
        }

        $event->getVisitor()->addData('original', $provider->getUrl($media));
    }
public function onPostSerialize ( ObjectEvent $ event ) { // getSubscribedEvents doesn't seem to support parent classes if ( ! $ event -> getObject ( ) instanceof MediaInterface ) { return ; } /** @var MediaInterface $media */ $ media = $ event -> getObject ( ) ; $ provider = $ this -> getProvider ( $ media ) ; if ( $ provider -> getName ( ) == 'image' ) { $ images = $ this -> getImages ( $ media , [ 'medialibrary' ] ) ; $ event -> getVisitor ( ) -> addData ( 'images' , $ images ) ; } $ event -> getVisitor ( ) -> addData ( 'original' , $ provider -> getUrl ( $ media ) ) ; }
Listens to the post_serialize event and generates urls to the different image formats.

@param ObjectEvent $event
Listens to the post_serialize event and generates urls to the different image formats .