[Resolved] srcset and sizes attributes

Home Forums Support [Resolved] srcset and sizes attributes

Home Forums Support srcset and sizes attributes

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1664304
    Carlos

    The theme generatepress is currently already managing correctly
    srcset and sizes attributes?

    example:

    The original image (3200px wide) is not in the srcset attribute. This is because by default, wordpress applies a 1600px limit to prevent themes that were not designed to work with adaptive images from loading huge images.

    This limit can be removed using this function
    apply_filters( ‘max_srcset_image_width’, int $max_width, int[] $size_array )

    The sizes attribute is very simplistic. It means that if the screen size is larger than the image, the width of the image must not exceed the defined size (300px or 525px). If the screen is smaller than the width of the image, the image must take the full width of the screen. We will say that this rule is well suited for designs that are not too complicated with images that take the full width of the screen up to a certain size. But for more advanced responsive sites, the sizes attribute must be modified so that the most suitable image is loaded in all cases!

    But since I am not a developer and what if my images with the generatepress theme do not respond … what can I do?

    #1665365
    David
    Staff
    Customer Support

    Hi there,

    thats correct WP’s method of adding sizes for your src-set attributes makes the assumption the image will fill the width of the viewport.

    If you feel the need to adapt that behaviour, you can use this filter: wp_calculate_image_sizes

    Which this article explains in detail:

    https://www.malthemilthers.com/responsive-images-and-how-to-implement-them-in-wordpress/

    #1668646
    Carlos

    Thanks

    #1668789
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.