No src and sizes attributes present on WordPress thumbnail images; the smallest image size is loaded irregardless of viewport size

WordPress Responsive Images Without Imagick

No, you do not need Imagick to get WordPress responsive images (srcset and sizes) working. As of WordPress 4.4+, if your theme has post-thumbnails enabled and you are using core functions like the_post_thumbnail() or wp_get_attachment_image(), WordPress will automatically include srcset and sizes attributes (assuming multiple image sizes exist). The GD library will suffice for generating those images.

Below are the main things to double-check to ensure WordPress automatically generates srcset:

  1. Confirm Theme Support for Thumbnails
    In your functions.php, you’ve already added:

function df_theme_support() {
add_theme_support(‘post-thumbnails’);

// Custom image sizes
add_image_size(‘small-thumbnail’, 430, 242, true);
add_image_size(‘medium-thumbnail’, 645, 363, true);
add_image_size(‘medium-large-thumbnail’, 860, 484, true);
}
add_action(‘after_setup_theme’, ‘df_theme_support’);

That’s correct for registering both thumbnail support and custom sizes.

  1. Use WordPress Image Functions
    When rendering images in your theme templates, make sure you’re using something like:

or

If you hardcode an <img> tag yourself (e.g., <img src="...">), then WordPress won’t have a chance to add srcset or sizes automatically.

  1. Ensure Images Are Large Enough
    WordPress only generates srcset attributes if the images are large enough to justify multiple sizes. If your original images are very small, the srcset might not appear. Make sure your uploaded images are bigger than your defined sizes so WordPress can generate the scaled versions.

  2. Regenerate Thumbnails (Optional)
    If the images were uploaded before you registered your new custom sizes, WordPress may not have generated those sizes yet. In that case, install and run the Regenerate Thumbnails plugin to force WordPress to generate the new image sizes.

  3. Imagick vs. GD
    You do not need Imagick installed for srcset to work. WordPress will happily generate resized images via GD if that’s the only library available. The presence of Imagick is optional and not required specifically for responsive image attributes.

Example
Putting it all together in a template (e.g., single.php or a custom template file):

Once that’s in place, WordPress will automatically generate the srcset and sizes attributes (again, assuming the source image is large enough and that multiple sizes exist).

Conclusion

  • You have correctly registered custom sizes.
  • Make sure you use WordPress functions (the_post_thumbnail() or wp_get_attachment_image()) to output images.
  • Regenerate thumbnails if needed.
  • GD alone is sufficient; Imagick is not strictly necessary.

This setup will ensure that WordPress adds responsive image attributes to your thumbnails out of the box. Happy coding!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)