src/Plugin.php
private function _getThumbnailUrl(EmbeddedAsset $embeddedAsset, int $size, int $maxSize = 200)
	{
		$assetManagerService = Craft::$app->getAssetManager();
		$defaultThumb = $assetManagerService->getPublishedUrl('@spicyweb/embeddedassets/resources/default-thumb.svg', true);

		// If embedded asset thumbnails are disabled, just show Embedded Assets' default.
		if (!$this->getSettings()->showThumbnailsInCp)
		{
			return $defaultThumb;
		}

		$url = false;
		$image = $embeddedAsset->getImageToSize($size);

		if ($image && UrlHelper::isAbsoluteUrl($image['url']))
		{
			$imageSize = max($image['width'], $image['height']);

			if ($size <= $maxSize || $imageSize > $maxSize)
			{
				$url = $image['url'];
			}
		}
		// Check to avoid showing the default thumbnail or provider icon in the asset editor HUD.
		else if ($size <= $maxSize)
		{
			$providerIcon = $embeddedAsset->getProviderIconToSize($size);

			if ($providerIcon && UrlHelper::isAbsoluteUrl($providerIcon['url']))
			{
				$url = $providerIcon['url'];
			}
			else
			{
				$url = $defaultThumb;
			}
		}

		return $url;
	}
private function _getThumbnailUrl(EmbeddedAsset $embeddedAsset, int $size, int $maxSize = 200)
	{
		$assetManagerService = Craft::$app->getAssetManager();
		$defaultThumb = $assetManagerService->getPublishedUrl('@spicyweb/embeddedassets/resources/default-thumb.svg', true);

		// If embedded asset thumbnails are disabled, just show Embedded Assets' default.
		if (!$this->getSettings()->showThumbnailsInCp)
		{
			return $defaultThumb;
		}

		$url = false;
		$image = $embeddedAsset->getImageToSize($size);

		if ($image && UrlHelper::isAbsoluteUrl($image['url']))
		{
			$imageSize = max($image['width'], $image['height']);

			if ($size <= $maxSize || $imageSize > $maxSize)
			{
				$url = $image['url'];
			}
		}
		// Check to avoid showing the default thumbnail or provider icon in the asset editor HUD.
		else if ($size <= $maxSize)
		{
			$providerIcon = $embeddedAsset->getProviderIconToSize($size);

			if ($providerIcon && UrlHelper::isAbsoluteUrl($providerIcon['url']))
			{
				$url = $providerIcon['url'];
			}
			else
			{
				$url = $defaultThumb;
			}
		}

		return $url;
	}
private function _getThumbnailUrl ( EmbeddedAsset $ embeddedAsset , int $ size , int $ maxSize = 200 ) { $ assetManagerService = Craft :: $ app -> getAssetManager ( ) ; $ defaultThumb = $ assetManagerService -> getPublishedUrl ( '@spicyweb/embeddedassets/resources/default-thumb.svg' , true ) ; // If embedded asset thumbnails are disabled, just show Embedded Assets' default. if ( ! $ this -> getSettings ( ) -> showThumbnailsInCp ) { return $ defaultThumb ; } $ url = false ; $ image = $ embeddedAsset -> getImageToSize ( $ size ) ; if ( $ image && UrlHelper :: isAbsoluteUrl ( $ image [ 'url' ] ) ) { $ imageSize = max ( $ image [ 'width' ] , $ image [ 'height' ] ) ; if ( $ size <= $ maxSize || $ imageSize > $ maxSize ) { $ url = $ image [ 'url' ] ; } } // Check to avoid showing the default thumbnail or provider icon in the asset editor HUD. else if ( $ size <= $ maxSize ) { $ providerIcon = $ embeddedAsset -> getProviderIconToSize ( $ size ) ; if ( $ providerIcon && UrlHelper :: isAbsoluteUrl ( $ providerIcon [ 'url' ] ) ) { $ url = $ providerIcon [ 'url' ] ; } else { $ url = $ defaultThumb ; } } return $ url ; }
Helper method for retrieving an appropriately sized thumbnail from an embedded asset.

@param EmbeddedAsset $embeddedAsset
@param int $size The preferred size of the thumbnail.
@param int $maxSize The largest size to bother getting a thumbnail for.
@return false|string The URL to the thumbnail.
Helper method for retrieving an appropriately sized thumbnail from an embedded asset .