[Resolved] WP Show Posts support for img src set

Home Forums Support WP Show Posts support for img src set

  • This topic has 13 replies, 2 voices, and was last updated 2 months ago by David.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1275501
    Matt

    Hey,

    Loving working with GP so far and using the Dispatch theme. It relies heavily on the WP Show Posts plugin, but a drawback is that this plugin doesn’t use the srcset property for images, so all images are being served at full size – even if they are being resized by the CSS.

    I appreciate you’re working on the changing it for Gutenberg at the moment but would like to suggest implementing this as a priority.

    I’d imagine quite a few others heavily weighed up the impact of speed when buying this theme – as I did. This currently impacts my site a fair bit and having images served at different size based on display size would be a massive help.

    #1276020
    Tom
    Lead Developer
    Lead Developer

    Hi Matt,

    As long as you don’t use the WPSP image width/height controls, they should use srcset like anything else.

    Can you check with those options empty?

    Let me know 🙂

    #1279348
    Matt

    Hey, I think this is to do with a cdn I have – thanks for the response though!

    #1279989
    Tom
    Lead Developer
    Lead Developer
    #1415696
    Evenit

    Hello,
    I am also using this plugin, is it possible to implement src set even when using WPSP image width/height controls?

    I need to use these controls in my article listings…

    Thanks
    Regards

    #1415869
    David
    Staff
    Customer Support

    Hi there,

    unfortunately not – if you change the sizes then it overwrites the srcset sizes.
    You can of course add more media attachment sizes to the srcset:

    https://docs.generatepress.com/article/adding-image-sizes/

    This would allow you to add sizes that are more conducive to your different responsive layouts.

    #1416289
    Evenit

    Thank you David, I see in the tutorial how to add new image sizes to my WordPress site, but it is not clear to me how to add the media attachment sizes to the srcset in the article lists I create with WPSP plugin.

    #1416640
    David
    Staff
    Customer Support

    I believe currently you can only set the Default size for ALL WPSP Images using this filter:

    add_filter( 'wpsp_default_image_size', function() {
        return 'your-size-name';
    } );

    You cannot currently set them differently for each list. Tom has it planned in for WPSP 1.2.

    However, how are you lists displayed on responsive views? ie. fewer columns with larger images on Tablet and Mobile. If thats the case then you probably want to leave src-set to do its thing and just create additional attachment sizes if required to fill that need.

    #1418408
    Evenit

    Hi David,
    I’m not sure I understand.
    In my case I would have, for example, a list with the following dimensions:
    2 columns with 640×360 images
    in the mobile version the images should become 423×238
    I hope I have better clarified my need.
    Thanks
    Regards

    Lorenzo

    #1418484
    David
    Staff
    Customer Support

    On load the browser will calculate the size of the image container, and with those dimensions selects the nearest image size available.

    You can therefore register images attachment sizes that are more appropriate for your site.

    Eg. A medium size of 440px to suit your mobile columns.

    #1418499
    Evenit

    So are you suggesting me not to set the image size with the WP Show Posts Controls? In this way it will use the native WordPress src set?
    If I understand correctly, it would be enough for me to create sizes that suits my needs with Regenerate Thumbnail plugin, correct?

    #1418531
    David
    Staff
    Customer Support

    Yes, thats correct 🙂

    #1418762
    Evenit

    In this way the problem I have is that all images in archives have different heights, so the archive page becomes ugly to see… maybe the best solution for me is to wait for the WPSP 1.2 release, so I can set the defalut size image for each list. Do you already know when the next release will come out?

    #1418780
    David
    Staff
    Customer Support

    When using the add image size you can just define the width, this will ‘auto’ the height and keep the original aspect ratio eg.:

    add_image_size( 'my-custom-image-name', 440 );

    WPSP Pro version 1.0 is still in alpha and this is next on our list of updates.
    We don’t have a definitive time line on 1.2 release just yet.

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.