• Hi there,

    I’m using the latest version of WordPress and the plugin. There is a problem in image markup in the frontend. The image HTML doesn’t include the height and width attribute and therefor I’m getting Lighthouse errors for images. Please add height and width attribute to featured images as soon as possible.

    And I would also like to see native lazy loading support for the images, as it is now included in WordPress itself, since 5.5.0.

    Thanks,
    Faisal Kabir

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Elvin

    (@ejcabquina)

    Hi,

    Images in the WPSP list has height and width attribute to its post image by default.

    It is only replaced when you specify values within the WPSP image settings. (Image width (px) and Image height (px))

    Also, loading="lazy" automatically applies to it assuming the mentioned image settings are left empty.

    We apologize for the delay in response.

    Happy holidays, stay safe. ??

    Thread Starter Faisal Kabir

    (@solvemethod)

    It doesn’t add height, width, and loading="lazy" if image settings (height/width) are customized. Can you please touch on that?

    Jill Caren

    (@jcarenoptonlinenet)

    I am having the same issue. There is no height or width appended in the source code which results in failing Lighthouse testing. I too have width and height settings specified.

    • This reply was modified 3 years, 10 months ago by Jill Caren.
    Plugin Support Elvin

    (@ejcabquina)

    Ah right yeah. In the context of Lighthouse testing, the more appropriate thing to try is this:

    Keep the image height and width empty and let’s control the image sizes by using the wpsp_default_image_size filter.

    Example: Adding a “thumbnail”(width=”150″ height=”150”) sized image.

    add_filter( 'wpsp_default_image_size', function() {
        return 'thumbnail';
    } );

    Or this:

    add_filter( 'wpsp_default_image_size', function() {
        return array(300, 150);
    } );

    But I doubt the array(300,150) will work exactly the way it’s intended as the image’s attributes will adjust to the size of its container.

    Say for example, if 300 is too large for its container, it will place a value that will fit its container instead of the 300 you’ve added.

    See here for the defaults. (You can register new image sizes if you want as indicated)
    https://developer.www.ads-software.com/reference/functions/the_post_thumbnail/#comment-280

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom image hight and width is missing in image attribute’ is closed to new replies.