• Resolved bluisier

    (@bluisier)


    Hi,

    First I can’t thank you enough for creating this plugin! It’s the first one (and maybe the only one) that actually uses native wp_gallery and implement nicely responsive images with srcset and sizes attr. Great job!

    I actually use your filter to customize my sizes attr the following way:

    
    add_filter( 'mgl_sizes', 'mgl_sizes_attr', 25, 4 );
    function mgl_sizes_attr( $sizes, $gallery_layout, $attachment, $attr ) {
        if ( $gallery_layout === 'justified' ) {
            $sizes = '(min-width: 861px) 500px, 100vw';
        }
        return $sizes;
    }
    

    The problem I’m facing is that for example with the justified layout I’m using on my website (you can see an example on the linked page), sometimes images take half the width and sometimes images are full width in the gallery. So my question is the following:

    Is there a way to customize the sizes attr for every image in the gallery in fonction of their displayed width?

    At the moment if an image displays in full width within the gallery on my website, quality is not perfect for this image.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jordy Meow

    (@tigroumeow)

    Hi @bluisier,

    So glad you noticed and appreciated how the plugin was built ?? To be honest, I was quite annoyed by the way the other galleries were built, and I believe this is the way it should have been done.

    In the filter, you can see that there is this $attachment variable. But you probably noticed that already. However, there is no way to know in advance in which size exactly the image will be displayed with that layout, as it is using CSS Flex. However, with a good old nice src-set and the right image-sizes, that should be good enough. Of course, the sizes attribute might not be perfect, and a bigger image than needed might be loaded but it would be difficult to get this right. There are services like Optimole which do this. There could be a way to do this but it’s technically a bit challenging relatively to the results and potential issues we will get. But why not one day?

    PS: Tu as un nouveau follower sur insta ??

    Thread Starter bluisier

    (@bluisier)

    Hey @tigroumeow ,

    I really appreciate and I just bought the pro version to support you guys.

    Yeah I was kind of expecting your answer and I can totally live with that. I will just continue too use it with this sizes attr which is good enough in most of the cases and good for performances.

    Just keep up your great work (I see that you have an affiliate area… that’s great as I might write a blog post on our pro website novo-media.ch about your plugin).

    P.S. tu as aussi un nouveau follower sur insta ??

    Plugin Author Jordy Meow

    (@tigroumeow)

    You are of course very welcome to write an article about it, using the affiliate links ?? Don’t hesitate to contact me through the support if you are interested in WP/LR Sync (as I will give a license to you!).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom sizes attr’ is closed to new replies.