Shopware-6-Blog-Plugin icon indicating copy to clipboard operation
Shopware-6-Blog-Plugin copied to clipboard

Wrong image sizes (blog detail page)

Open timonf opened this issue 2 years ago • 5 comments

Hi Christopher,

we use your blog plugin and we are very happy with it. But when it comes to image resizing and thumbnails it has a strange behaviour.

First of all there is only one default thumbnail size (650px) for blog teaser images after installation (src/SasBlogModule.php):

        $mediaFolderRepository->create([
            [
                'entity' => BlogEntriesDefinition::ENTITY_NAME,
                'associationFields' => ['media'],
                'folder' => [
                    'name' => 'Blog Images',
                    'useParentConfiguration' => false,
                    'configuration' => [
                        'createThumbnails' => true,
                        'mediaThumbnailSizes' => [
                            [
                                'width' => 650,
                                'height' => 330,
                            ],
                        ],
                    ],
                ],
            ],
        ], $context);

But the default width of images on blog detail page using default Storefront theme is 893.33px. So the images don't look good:

image

So we have to adjust the generated thumbnails... So I went with 308px (for blog listing) and 893px (for detail page):

image

But after I changed it, it's getting worse.... because the desktop version now uses the 308px version (firefox is used):

image

I guess something is misconfigured in this part of code (src/Resources/views/storefront/element/cms-element-blog-detail.html.twig):

                            {% sw_thumbnails 'blog-image-teaser' with {
                                    media: element.data.media,
                                    sizes: {
                                    'xs': '501px',
                                    'sm': '315px',
                                    'md': '427px',
                                    'lg': '333px',
                                    'xl': '284px'
                                }
                            } %}

Why this template uses small images on xl and large images on xs? After resizing the window to a smaller viewport I will see the sharp version (893px) of the image:

image

Proposals:

  • Add two versions of thumbnails in SasBlogModule.php (one for listing, one for teaser)
  • Use only large images in src/Resources/views/storefront/element/cms-element-blog-detail.html.twig (maybe smaller thumbnails version on very small viewports)

But it would be even better, if you could configure those sizes.

timonf avatar Jun 02 '22 09:06 timonf

Hi @timonf, thanks for your feedback and helpful suggestion. We'll discuss and find the best solution to fix it soon.

viennt avatar Jun 02 '22 10:06 viennt

Hi @viennt!

If you like, I could create a PR :)

timonf avatar Jun 02 '22 11:06 timonf

Sure, that sounds great to me ^^

viennt avatar Jun 02 '22 12:06 viennt

@viennt Any status for the open PR?

timonf avatar Jul 01 '22 09:07 timonf

@timonf, sorry for the late response. I'm checking it now. Thank you again for the PR.

viennt avatar Jul 03 '22 07:07 viennt