Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
MediaThumbnailSizeEntity example
$criteria
=
new
Criteria
(
[
$media
->
getId
(
)
]
)
;
$criteria
->
addAssociation
(
'mediaFolder.configuration.mediaThumbnailSizes'
)
;
/** @var MediaEntity $media */
$media
=
$this
->mediaRepository->
search
(
$criteria
,
$this
->context
)
->
get
(
$media
->
getId
(
)
)
;
static
::
assertInstanceOf
(
MediaFolderEntity::
class
,
$media
->
getMediaFolder
(
)
)
;
static
::
assertInstanceOf
(
MediaFolderConfigurationEntity::
class
,
$media
->
getMediaFolder
(
)
->
getConfiguration
(
)
)
;
$media
->
getMediaFolder
(
)
->
getConfiguration
(
)
->
setMediaThumbnailSizes
(
new
MediaThumbnailSizeCollection
(
[
(
new
MediaThumbnailSizeEntity
(
)
)
->
assign
(
[
'id' => Uuid::
randomHex
(
)
,
'width' => 1530,
'height' => 1530,
]
)
,
]
)
)
;
$media
->
getMediaFolder
(
)
->
getConfiguration
(
)
->
setThumbnailQuality
(
100
)
;
$filePath
=
$this
->urlGenerator->
getRelativeMediaUrl
(
$media
)
;
$resource
=
fopen
(
__DIR__ . '/../fixtures/shopware_optimized.jpg', 'rb'
)
;
\
assert
(
$resource
!== false
)
;