0

I upload mainly light images (around 40 kb's) to my site and also want to save room on my server and don't use 4 different folders for images --- is there any way to avoid using the Drupal image styles system? Can I safely remove the image style folders (or most of their files) and that's it? --- I will check all site pages afterwards and re add images if needed, I just don't have many pages (I have about 30). Thx.

2 Answers 2

3

The Drupal image style system let you upload an image in whatever form you choose, and the image style will transform it into the size, shape, etc. of the selected style according to preset rules that you find in the configuration for image styles.

One of the benefits of the Image style system is that it allows reuse of images in different styles. You just upload the image once, and than you can use a thumbnail size version in the teaser, and a large size in the main article - or two different styles of the same image in two different nodes, etc.

There is one folder per style (I believe there are 4 default styles, but you can create and add your own styles if you want to, and this will add more folders below the styles directory).

Drupal does not create a copy of the image for a particular style until that style is requested. While there are 4 folders, if you don't reuse an image, it will only be created in one style - meaning that there will be two copies of that image on your disk: The original, and the scaled, cropped, whatever, copy that Drupal has created for that style.

In other words, you need to condsider the (IMHO) substantial benefits of Drypal's image style system before you decide to get rid of it.

But if you don't want to use it, you can do without.

However it is a bit more involved than just removing the image style folder.

Basically, what you do is to resize, crop, etc. the image yourself, before you upload it to the site. Then you create (by hand) a link to the original that you've uploaded from whereever you want to use it. If you do this with all images, Drupal will never attempt to create a copy for a particular image style and the image style folder will be empty.

If you're sure you're never is going to allow Drupal to style an image, I suppose you can remove the image style folder at this point, but I would leave the empty folder it in place to avoid breaking the site if I at some point forget that I'm not supposed to use Drupal's image styles.

If you think that a lot of unused copies of images are living below the image styles folder, you can flush all (or a subset) with the following Drush CLI command:

drush image-flush

This leaves the file structure below the image styles folder in place, so if a flushed image is requested, it will automatically be recreated in the requested style.

2
  • If I want to clear the styles folders totally, but also want to keep some already-used images, should I just put these desired images in the "files" folder and that's it?
    – user16289
    Jun 15, 2015 at 10:36
  • 1
    You can put them whereever you like, as long as you make sure the links to them from the nodes have the right path. Moving images without fixing links will break the images. Jun 15, 2015 at 14:23
0

If you don't want to use image styles, then you can change the display settings on each image field to use the "Original image" style.

Go to admin > Structure > Content types > Page [or your type here...] > Manage display.

For any image field, click the cog-wheel at the extreme right of the row, and select "Original image" from the drop down.

This will prevent Drupal from using it's image styles for any post of this (Page [or your type here...]) type.

Additionally, you could disable the image module to prevent the use of image styles. However, this will also have the (likely unwanted) effect of removing the upload-an-image ability - and will delete any existing images you have uploaded this way when the module is uninstalled.

I recommend, instead, leaving the image module enabled and instead configuring your posts not to use image styles where they are not wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.