Programming Language PHP

Namespace Instagram\Model

Class MediaDetailed

Method/Function setSideCarItems

Total Examples 1

1 code examples of PHP Instagram\Model\MediaDetailed::setSideCarItems extracted from open source projects

Was this example useful?
0
                                                    /**
     * @return MediaDetailed
     * @throws InstagramFetchException
     */
    private function mediaDetailedCarouselHydrator(MediaDetailed $media, \StdClass $node): Media
    {
        $scItems = [];
        foreach ($node->carousel_media as $key => $item) {
            $scItem = new MediaDetailed();
            $scItem->setId((int) $item->pk);
            $scItem->setShortCode($node->code);
            $scItem->setHeight($item->original_height);
            $scItem->setWidth($item->original_width);
            $scItem->setTypeName($this->getTypeName($item->media_type));
            $scItem->setDisplayResources($item->image_versions2->candidates);

            $scItem->setVideo($this->isVideo($node));

            if (property_exists($item, 'video_versions')) {
                foreach ($item->video_versions as $video) {
                    if ($video->type == 101) {
                        $videoSrc = $video->url;
                    }
                }
                $scItem->setVideoUrl($videoSrc ?? null);
            }

            $scItems[] = $scItem;

            if ($key == 0) {
                $media->setDisplayResources($item->image_versions2->candidates);
            }
        }

        $media->setSideCarItems($scItems);

        return $media;
    }