Load gallery images
@param $id
@param string $thumbnail
@return array
492353
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;
    }
1330548
public function actionCreateImage($id)
    {
        $gallery = $this->findModel($id);

        $model = $this->module->manager->createGalleryImage(['scenario' => 'create']);

        $model->loadDefaultValues();

        if ($model->load(\Yii::$app->request->post())) {
            $model->gallery_id = $gallery->id;
            if($model->create()) {
                \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been created'));
                return $this->redirect(['images', 'id' => $id]);
            }
        }

        return $this->render('image/create', [
            'gallery' => $gallery,
            'model' => $model
        ]);
    }
229094
public function getImages(int $id): ImageStatistics
    {
        $json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/images');

        return DataParser::parseData($json, ImageStatistics::class);
    }
32487
public function picture($id, $name, $email, $thumbnail = true)
	{
		if ($thumbnail)
		{
			$this->set('size', 300);
		}

		$url  = $this->get('secure') === true ? $this->secureBaseUrl : $this->publicBaseUrl;
		$url .= htmlspecialchars($this->hash($email));
		$url .= $this->extension();
		$url .= $this->parameters();

		return $url;
	}
1143089
public function read( $id )
	{
	    if ( $this->has( $id ) )
		{
			return \CCJson::read( $this->file_path( $id ) );
		}
		
		return array();
	}
668735
public static function get( $id ) {
		if ( file_exists( Utils\get_snapshot_directory() . $id . '/meta.json' ) ) {
			$meta_file_contents = file_get_contents( Utils\get_snapshot_directory() . $id . '/meta.json' );
			$meta               = json_decode( $meta_file_contents, true );
		} else {
			$meta = [];
		}

		/**
		 * Backwards compant - need to fill in repo before we started saving repo in meta.
		 */
		if ( empty( $meta['repository'] ) ) {
			Log::instance()->write( 'Legacy snapshot found without repository. Assuming default repository.', 1, 'warning' );

			$meta['repository'] = RepositoryManager::instance()->getDefault();
		}

		return new self( $id, $meta['repository'], $meta );
	}
911248
public function view($slug = null, $id = null)
    {
        //This allows backward compatibility for URLs like `/photo/11`
        if (empty($slug)) {
            $slug = $this->Photos->findById($id)
                ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['slug']]])
                ->extract('album.slug')
                ->first();

            return $this->redirect(compact('id', 'slug'), 301);
        }

        $photo = $this->Photos->findActiveById($id)
            ->select(['id', 'album_id', 'filename', 'active', 'modified'])
            ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['id', 'title', 'slug']]])
            ->cache(sprintf('view_%s', md5($id)), $this->Photos->getCacheName())
            ->firstOrFail();

        $this->set(compact('photo'));
    }
1196959
public function assetsGet($id)
    {
        $resource = '/assets/' . $id . '.json';

        // Create request
        $data = $this->auth->request('GET', $resource);

        return $data;
    }
1041619
public static function getByID($id)
    {
        if ($id) {
            $app = Application::getFacadeApplication();
            $em = $app->make(EntityManagerInterface::class);
            $result = $em->find(ThumbnailTypeEntity::class, $id);
        } else {
            $result = null;
        }

        return $result;
    }
1288151
public function thumbnailElement($file_id)
    {
        /** @var LazaretFile $lazaretFile */
        $lazaretFile = $this->getLazaretFileRepository()->find($file_id);

        if (null === $lazaretFile) {
            return new Response(null, 404);
        }

        $lazaretThumbFileName = $this->app['tmp.lazaret.path'].'/'.$lazaretFile->getThumbFilename();

        return $this->deliverFile(
            $lazaretThumbFileName,
            $lazaretFile->getOriginalName(),
            DeliverDataInterface::DISPOSITION_INLINE,
            'image/jpeg'
        );
    }
108164
public function getFrames($id, $type)
    {
        $dom = $this->browser->getDom('/'.$type.'/'.$type.'_photos.php?id='.$id);
        if (!$dom) {
            return [];
        }
        $images = (new \DOMXPath($dom))->query('//table//table//table//img');
        $frames = [];
        foreach ($images as $image) {
            $src = $this->getAttrAsArray($image)['src'];
            $entity = new Image();
            if ($type == self::ITEM_TYPE_ANIMATION) {
                $src = str_replace('optimize_b', 'optimize_d', $src);
                if (strpos($src, 'http://') === false) {
                    $src = $this->browser->getHost().'/'.$type.'/'.$src;
                }
                if (preg_match('/\-(?<image>\d+)\-optimize_d(?<ext>\.jpe?g|png|gif)/', $src, $mat)) {
                    $entity->setSource(self::NAME.'/'.$id.'/'.$mat['image'].$mat['ext']);
                    if ($this->uploadImage($src, $entity)) {
                        $frames[] = $entity;
                    }
                }
            } elseif (preg_match('/_(?<round>\d+)\/.+\/(?<id>\d+)-(?<image>\d+)-.+(?<ext>\.jpe?g|png|gif)/', $src, $mat)) {
                $src = $this->browser->getHost().'/'.$type.'/img/'.$mat['round'].'/'.$mat['id'].'/'.$mat['image'].$mat['ext'];
                $entity->setSource(self::NAME.'/'.$id.'/'.$mat['image'].$mat['ext']);
                if ($this->uploadImage($src, $entity)) {
                    $frames[] = $entity;
                }
            }
        }

        return $frames;
    }
497940
public function get_thumbnail($key = 0)
	{
		$thumbnails = $this->get_thumbnails();
		if (isset($thumbnails[$key]))
		{
			return $thumbnails[$key];
		}

		return null;
	}
822807
private function load($id)
    {

        $this->initialize();
        $this->id = $id;
        $ok = $this->dataConnector->loadToolProxy($this);
        if (!$ok) {
            $this->enabled = $autoEnable;
        }

        return $ok;

    }
1370022
private function buildSizedImgixImage($id, $size) {
		$meta = wp_get_attachment_metadata($id);
		if(!$meta || empty($meta)) {
			return false;
		}

		if(!isset($meta['s3'])) {
			return [];
		}

		$imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS);

		if($this->signingKey) {
			$imgix->setSignKey($this->signingKey);
		}


		$is_crop = ((count($size) >= 3) && ($size[2] == 'crop'));
		if (!$is_crop && $this->shouldCrop) {
		    $this->shouldCrop = false;
		    $is_crop = true;
        }

        if ($is_crop && (($size[0] === 0) || ($size[1] === 0))) {
		    if ($size[0] === 0) {
		        $size[0] = 10000;
            } else {
		        $size[1] = 10000;
            }

		    $is_crop = false;
        }

		if(isset($size['width'])) {
			$size = [
				$size['width'],
				$size['height']
			];
		}

		$params = [
			'fit' => ($is_crop) ? 'crop' : 'fit',
			'w' => $size[0],
			'h' => $size[1],
			'fm' => 'jpg'
		];
		$params = apply_filters('ilab-imgix-filter-parameters', $params, $size, $id, $meta);

		$imageFile = (isset($meta['s3'])) ? $meta['s3']['key'] : $meta['file'];

		$result = [
			$imgix->createURL(str_replace('%2F', '/', urlencode($imageFile)), $params),
			$size[0],
			$size[1]
		];

		return $result;
	}
187798
private function generateGlobalThumb($id)
    {
        $resource = HCResources::find($id);

        if( ! file_exists(storage_path('app/') . $resource->path) )
            return;

        if( strpos($resource->mime_type, 'image') === false || strpos($resource->mime_type, 'svg') !== false )
            return;

        if( ! $resource )
            throw new \Exception('Resource not found: ' . $id);

        $thumbRules = HCThumbs::where('global', 1)->get();
        $dest = implode('/', str_split(str_pad($resource->count, 9, '0', STR_PAD_LEFT), 3)) . '/';

        foreach ( $thumbRules as $rule ) {
            $destination = generateResourcePublicLocation($dest, $rule->width, $rule->height, $rule->fit) . $resource->extension;
            createImage(storage_path('app/') . $resource->path, $destination, $rule->width, $rule->height, $rule->fit);
        }
    }
1361684
public function getWidgetImages(int $widgetID, string $collection): array
    {
        $widget = $this->getWidgetObject($widgetID);
        $images = $widget->getMedia($collection);

        $media = [];

        foreach ($images as $mediaItem) {
            $data = [
                'id' => $mediaItem->id,
                'src' => url($mediaItem->getUrl()),
                'thumb' => ($mediaItem->getUrl($collection.'_admin')) ? url($mediaItem->getUrl($collection.'_admin')) : url($mediaItem->getUrl()),
                'properties' => $mediaItem->custom_properties,
            ];

            $media[] = $data;
        }

        return $media;
    }
1056452
public function loadSnapshot(Identity $id)
    {
        if (is_null($this->snapshotStore)) {
            throw new \Exception('Unable to get snapshot; No store attached');
        }

        return $this->snapshotStore->get($id);
    }