public function apply($transformer, $instant_article, $node) { // Builds the slideshow $slideshow = Slideshow::create(); $instant_article->addChild($slideshow); $gallery = $this->getProperty(self::PROPERTY_JETPACK_DATA_GALLERY, $node); if ($gallery && isset($gallery)) { foreach ($gallery as $gallery_image) { // Constructs Image if it contains URL if (!Type::isTextEmpty($gallery_image['src'])) { $image = Image::create(); $image->withURL($gallery_image['src']); // Constructs Caption element when present in the JSON if (!Type::isTextEmpty($gallery_image['caption'])) { $caption = Caption::create(); $caption->appendText($gallery_image['caption']); $image->withCaption($caption); } $slideshow->addImage($image); } } } $transformer->transform($slideshow, $node); return $instant_article; }
public function apply($transformer, $instant_article, $node) { // Builds the slideshow $slideshow = Slideshow::create(); $instant_article->addChild($slideshow); $transformer->transform($slideshow, $node); return $instant_article; }