• Resolved adriansr

    (@adriansr)


    Hi. Firstly, thanks a lot for your great plugin. πŸ™‚

    I’m currently trying out stuff on a temporary private website.

    Problem:
    The markup for the related post image does not have srcset. The plugin shows the correct image (AKA the post’s thumbnail or featured image), but there is no srcset. I need srcset to reduce bandwidth usage.

    Using Chrome’s inspect tool, this is the markup I get:
    <img src="https://mydomain.com/cms/wp-content/uploads/2020/09/water_drops-copy-652x408.jpg" class="crp_thumb crp_featured" alt="Media Settings Tester" title="Media Settings Tester">

    OTHER INFO:

    The file “water_drops-copy-652×408.jpg” has multiple sizes automatically created by WordPress. I verified this using my control panel’s File Manager to check inside the Uploads folder.

    WordPress version: 5.5.1
    Theme: TwentySeventeen version 2.4
    Plugins installed:
    1. Contextual related posts
    2. Hide My Site (to make the site private because it is for testing/development only)
    3. Regenerate Thumbnails

    My CRP Thumbnail settings
    (WP Admin > Settings > Related Posts > Thumbnail):
    Location of the post thumbnail: Display thumbnails inline with posts, before title.
    Thumbnail size: thumbnail (652×408)
    Hard crop thumbnails: unchecked.
    Generate thumbnail sizes: unchecked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter adriansr

    (@adriansr)

    I found an improvisation (a semi-solution). I cannot really call this a solution because, ideally, “srcset” should appear when other registered image sizes are used, not just crp_thumbnail.

    The improvisation:
    Srcset appears in the markup only when ALL of the following conditions are true:
    1. “crp_thumbnail” is selected in Settings > Related Posts > Thumbnail > Thumbnail size.
    2. A width is specified in Settings > Related Posts > Thumbnail > Thumbnail width.
    3. A height is specified in Settings > Related Posts > Thumbnail > Thumbnail height.
    4. The specified width and height match the width and height of a registered image size.

    • This reply was modified 3 years, 6 months ago by adriansr.
    • This reply was modified 3 years, 6 months ago by adriansr.
    Plugin Author Ajay

    (@ajay)

    The plugin uses WordPress’ srcset implementation and not a separate one. The most important criteria I thought was point 4 above and was independent of the first one.

    2, 3 and 4 are all linked together

    I’ll take a look at it again to see on point 1 – but I don’t recall specifically checking for crp_thumbnail to generate the srcset.

    https://github.com/WebberZone/contextual-related-posts/blob/5f7000cc1c83918636076493d346805f7c95b3a5/includes/media.php#L335

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CRP Image missing srcset’ is closed to new replies.