Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getThumbnailSizesFromMedia example
public
function
createMediaThumbnail
(
Media
$media
,
$thumbnailSizes
=
[
]
,
$keepProportions
= false
)
{
$imagePath
=
$media
->
getPath
(
)
;
if
(
$media
->
getType
(
)
!==
$media
::TYPE_IMAGE
)
{
throw
new
Exception
(
sprintf
(
'File %s is not an image.',
$imagePath
)
)
;
}
if
(
empty
(
$thumbnailSizes
)
)
{
$thumbnailSizes
=
$this
->
getThumbnailSizesFromMedia
(
$media
)
;
$thumbnailSizes
=
array_merge
(
$thumbnailSizes
,
$media
->
getDefaultThumbnails
(
)
)
;
}
$albumSettings
=
$this
->
getAlbumSettingsFromMedia
(
$media
)
;
if
(
$albumSettings
)
{
$highDpi
=
$albumSettings
->
isThumbnailHighDpi
(
)
;
$standardQuality
=
$albumSettings
->
getThumbnailQuality
(
)
;
$highDpiQuality
=
$albumSettings
->
getThumbnailHighDpiQuality
(
)
;
}
else
{
$highDpi
= false;
$standardQuality
= 90;