public function loadGalleryThumbs($id, $thumbnail = 'thumbnail')
    {
        $gallery = $this->entityTypeManager
            ->getStorage('media')
            ->load($id);

        $images = $gallery->get('field_media_images');
        $result = [];

        if($images)
        {
            foreach($images as $image)
            {
                $mid        = $image->entity->id();
                $fileEntity = $image->entity->field_image->entity;
                $fid        = $image->entity->field_image->entity->id();
                $imageUrl   = $fileEntity->getFileUri();

                $result[] = [
                    'mid'   => $mid,
                    'fid'   => $fid,
                    'thumb' => ImageStyle::load($thumbnail)->buildUrl($imageUrl),
                ];
            }
        }


        return $result;
    }
public function loadGalleryThumbs($id, $thumbnail = 'thumbnail')
    {
        $gallery = $this->entityTypeManager
            ->getStorage('media')
            ->load($id);

        $images = $gallery->get('field_media_images');
        $result = [];

        if($images)
        {
            foreach($images as $image)
            {
                $mid        = $image->entity->id();
                $fileEntity = $image->entity->field_image->entity;
                $fid        = $image->entity->field_image->entity->id();
                $imageUrl   = $fileEntity->getFileUri();

                $result[] = [
                    'mid'   => $mid,
                    'fid'   => $fid,
                    'thumb' => ImageStyle::load($thumbnail)->buildUrl($imageUrl),
                ];
            }
        }


        return $result;
    }
public function loadGalleryThumbs ( $ id , $ thumbnail = 'thumbnail' ) { $ gallery = $ this -> entityTypeManager -> getStorage ( 'media' ) -> load ( $ id ) ; $ images = $ gallery -> get ( 'field_media_images' ) ; $ result = [ ] ; if ( $ images ) { foreach ( $ images as $ image ) { $ mid = $ image -> entity -> id ( ) ; $ fileEntity = $ image -> entity -> field_image -> entity ; $ fid = $ image -> entity -> field_image -> entity -> id ( ) ; $ imageUrl = $ fileEntity -> getFileUri ( ) ; $ result [ ] = [ 'mid' => $ mid , 'fid' => $ fid , 'thumb' => ImageStyle :: load ( $ thumbnail ) -> buildUrl ( $ imageUrl ) , ] ; } } return $ result ; }
Load gallery images
@param $id
@param string $thumbnail
@return array
Load gallery images