0

I believe I understand this about Drupal 8: every image uploaded will automatically be created in each of the image styles I have set up (or the default 3 that come with core).

This incentivizes me NOT to create very many image styles, because then I'll end up with a bunch of different copies of my original image, whether they will ever be used in that particular style or not.

Is that correct?

On the other hand, Molot's answer over here mentions that "styled image files are supposed to be created on first access". That gives me hope that if I upload an image, it will only be created in an image style the first time it is requested in that image style. That means I could have as many custom image styles as I need and not worry that an image will be created for each one of those every time.

For example, if I have 12 custom image styles, but I only call a certain image in one style, will I end up with only 2 copies of the image, one as the original upload and one in the only style I called? This is what I would love to be true.

Thanks for any insight.

  • I only call a certain image in one style, will I end up with only 2 copies of the image, one as the original upload and one in the only style I called? Yes. – No Sssweat Nov 1 '16 at 6:50
  • They are saved in the /sites/default/files/styles folder, in case you are wondering. – No Sssweat Nov 1 '16 at 6:52
3

The styled images will be created on first request, creating a new file with the styled image. This will not only save space if you have tons of image styles but also CPU power - because if you attach 10 images to a node and want to create 12 (as you mention the number) different image styles, that will put quite a load to generate all the styled images in one go. Doing this when needed is far better management of resources.

  • To make sure I understand, the first time I call an image it creates the image style needed on that page and NO other? Or the first time I call an image, it creates all the image styles I ever specified? – Leraa Oct 31 '16 at 14:56
  • If you go to a page that you defined to show an image with style A, then only the file that corresponds to that style A will be created, no others. – kufeiko Oct 31 '16 at 14:59

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.