We have an image field (field_image) that did not have an image style originally applied. In the end we have hundreds of nodes (pages) where the Image style is not present. When adding an image style to the field under the respective View Mode, we are still getting an image without the image style applied.

How can we enforce the image style to be applied to currently published nodes?

Current results:

<img src="sites/default/files/image-original.jpg">

Desired results:

<img src="sites/default/files/styles/large/image-original.jpg">

What we have tried that didn't work:

  1. Flush image style
  2. Cleared cache
  • A cache clear should be all you need I think, just so the content is rebuilt next time it's requested. If the changes aren't applying, maybe the image isn't being rendered with the field formatter. Check any custom node templates, you might find it needs to be changed in there. Or maybe other layers of cache are getting you (varnish, browser, etc) – Clive Mar 8 '18 at 20:36
  • @Clive I checked some of the templates and it does display the image in some instances as "file_url(content.field_image.0['#items].entity.url.value)". The current field formatter says Image, let me try changing it to URL to image to see if that resolves the issue. In other twig templates we are displaying "{{ content.field_image}}" – usernameabc Mar 8 '18 at 23:19

Start by checking your admin logs for one and second make sure that the new style directory permissions are correct. Image styles Troubleshooting -That's assuming that the images are being created and the folder(s)'s .htaccess is all good.

Also maybe force it by adding your specific style as argument using drush if MACHINE_NAME

| improve this answer | |

I had to switch the formatter to Image and the twig templates to use the {{ content.field_image }} to get this to work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.