Hi,

I need to be able to delete the original files which users upload due to the storage requirements of keeping the (often large) original around. The attached adds a new 'save original file' option, which defaults to the current behaviour. If it is false then the image is deleted in the _image_build_derivatives function instead of being added to $node->images[]. There is also a check added to ensure that an original file exists before outputting a link to it in the case that 'image_view_original' is true.

For me it is essential that I can delete the original files (I have over 500 images online at the moment), and I assume there are many users in a similar situation with regard to diskspace or who will be if users can upload large original files.

Please let me know if this is considered desirable and if it should be achieved in any other way. I wasn't exactly sure where the best place to delete this file was, but this seemed like the most hassle free place.

Cheers,
Eric

CommentFileSizeAuthor
image.module.delete_original.patch1.53 KBejort
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

walkah’s picture

The original is deliberately saved so that later sizes can be regenerated without loss of quality. if you're that worried about storage - resize the originals prior to upload.

ejort’s picture

Just a few data points on this from my perspective. Feel free to disagree, I'm happy to maintain this patch locally as it definitely makes sense for my case:

o While keeping the originals around for the possibility of later high quality resizing is a good goal, resizing images to something close to the preview size before uploading them as a workaround for my problem also negates this possibility (with other associated negatives). So I still lose the advantage and gain most of the disadvantages

o Most of my users aren't technically savvy people and I'd like to lower the barrier to entry for the image galleries as much as possible, if they have to edit each picture in between downloading from the camera and submitting it to the site then they'll probably not bother (or know how to do it properly)

o This still doubles my storage space requirements, even if I can manage to get all my users to downsize images before submitting them.

Cheers,
Eric

likoma’s picture

Just adding my vote for this feature as 92% of my clients don't know how to "resize before upload" and they'll always have the full-size image on their computers (or I will).

I tried adding this patch to the 4.6.3 version, but I now see it's a CVS version and that didn't work. I tried using the CVS version of the module in my 4.6.3 install, but that didn't work either. I'll wait until this is implemented (?) into the next regular install version.

benshell’s picture

Personally I really like the way Drupal imaging works now, but I can see your point about running out of space. In my case I have plenty of server space and only a few users that upload pictures, so it's not a problem. However, I don't think it would be a good idea to delete the image marked _original. Other modules may try to access the original. For example, in my work on img_assist I added the ability to make additional derivatives from the original (this will be part of img_assist for 4.7).

So here's my idea: Why don't you use a cron task to delete the original file from the disk (like you're doing now in your patch), and then in the database files table copy the filepath and filesize for the preview image to the filepath/filesize of the original? Someone please speak up if you can think of a reason why this wouldn't work. You'd lose the benefits of having a high quality full resolution original, but I would you'd be less likely to break other Drupal modules that use the original. Also, by using a cron task you won't have to change any existing modules, and you won't have to worry about it working with future image.module compatible modules.

Norne’s picture

Has anybody made this work? I am setting up a site for a group of freelance journalists and travelling photographers. They are creative people, but they don't know much about "technical stuff", and they are always in a hurry, always on the road.

They store hundreds of GB of photos and they want to show many of them as previews for the customers, but they need to protect the originals until they have sold the article.

So I need a solution for them to upload the originals and have them resized by the server, and then the originals need to be gone for a period of time. When decisions are made on what pictures to use on print, the original can be uploaded as an attachment to the last revision of the article (situated in another folder, untouched by the deletion function).

This decisionmaking can take a few minutes or a few weeks, so a cron would not be the best solution here. It would have to run very often, so it would slow down the server (and the server load is pretty heavy already with all this resizing). The patch would work, I guess... If it works.

I'm new to Drupal, but it looks promising. Can I make it do the job, or will I need another solution for this? I don't think it would be possible in the CMS I normally use (Joomla or Xoops), but it could work here... I must admit that I haven't checked out the gallery applications yet, because I'm not used to working with this large amount of pictures.

The solution with the patch would be perfect, but HOW and WHERE to put it? Has anybody tried it out yet? If it is not a good solution, does anybody have other suggestions on how to solve this?

Jax’s picture

bookmarked.

ilbeppe’s picture

I have the same problem i want to delete original image!

There is a patch for the 1.6 version??