While using the image module, I found that if I set the preview size to a size the same or larger than the original, the preview image that is generated is a copy of the original with "_0" added to the name of the file. For example: image_0.jpg.
If I go to image settings and click on "Save configuration," even without changing any settings, the original image will then show up as the preview image. The copy of the file with the "_0" is then no longer accessible. Is this normal?
I would like the original image to be used as the preview image by default if it's the same or smaller than the defined preview size so that identical copies don't take up extra server space. Is there a way to enable this?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | original_as_derivative_0.patch | 1.05 KB | Montuelle |
| #2 | original_as_derivative.patch | 1.08 KB | Montuelle |
Comments
Comment #1
Montuelle commentedI am running the CVS versions of Drupal 4.7 and image.module (with the patch in drupal.org/node/50889).
I also have the same problem: for all original images having a size equal or lower than the preview size there are duplicated files in files/images. For examples:
image1234.jpg
image1234.thumbnail.jpg
image1234_0.jpg
This is not the case in the files/images/temp folder:
image1234.jpg
image1234.thumbnail.jpg
In the database the preview points to image1234_0.jpg and _original to image1234.jpg
As in my case, I want to limit the space used by images by uploading original having the preview size (800x600) this is unfortunate because in fact I use twice the space really needed.
Comment #2
Montuelle commentedThis my first patch submission to Drupal. Be indulgent.
It is based on the fact that if a derivative is missing
image_load()replaces it by the original. For example:So when the original is equal or smaller than the derivative, the derivative does not need to be created. It is what my patch does in
image_insert()and inimage_update()I have tested when the original size == preview size. When original < thumbnail. I have also tried all sort of updates (to bigger or smaller images) and deletes. It seems to work.
Comment #3
Montuelle commentedI must add that you must also apply the patch in drupal.org/node/50889 to be able to run image.module with the CVS version of Drupal 4.7.
Comment #4
neclimdulCode works as intended. I'd say this might cause a problem if images are resized if/when label sizes are changed but this doesn't happen anyways. This to me is a good idea and it works well with the link building patch.
Comment #5
Montuelle commentedJames, thanks for your review. Could the status be changed to "ready to be committed"?
Comment #6
dtmatthes commentedWhen I tried to run the original_as_derivative.patch using Cygwin, I received the following message:
missing header for unified diff at line 2 of patch
(Stripping trailing CRs from patch.)
patching file image.module
patch: **** malformed patch at line 7: @@ -359,11 +359,13 @@
Thanks for your help.
Comment #7
dtmatthes commentedCan you point me to a resource that explains how to implement the original_as_derivative.patch, since I couldn't seem to get it to work by using the patch command and Cygwin.
Comment #8
Montuelle commentedIn the Drupal handbook there is a chapter Patching with Cygwin.
But as it is my first patch, it could be a problem with the way I have produced it. I have used WinMerge on Windows. I will try to produce another version by using Diff from Gnuwin32. I will also save the file with "Linux line-ends". I am trying to figure out from drupal.org/diffandpatch how to do all this.
Sorry but I have never applied a patch directly on my server. For the rare cases where I needed to modify the Drupal source, I did it "by hand" (cut and paste with a text editor on my computer and then FTP upload).
Comment #9
Montuelle commentedHere is the patch file as produced by Eclipse on Windows and with unix line endings.
@dtmatthes: could you report if this is working for you now. Thanks.
Comment #10
neclimdulI've been using this for a while now and haven't run into any problems.
+1 to commit
Comment #11
dtmatthes commentedMontuelle: The original_as_derivative_0.patch seemed to work just fine with Cygwin, and it seems to have fixed the original issue. Thanks!
Comment #12
walkah commentedcommitted a modified version of this (centralized the check to _insert_image() ). thanks!
Comment #13
(not verified) commentedComment #14
Hetta commentedThis is still a problem for both the dev version (May 27, 2007) and the production version (5.x-1.1, May 2, 2007).
It needs fixing, VERY badly.
Comment #15
drewish commentedHetta, i really appreciate that you looked for an existing issue before creating an new one but this has been closed for over a year and the code has changed enough between then and now that it's probably not the same bug. please open up a new issue for it.
Comment #16
Hetta commentedI believe this is the same issue as well: http://drupal.org/node/142233 - that one is still open.
Thanks!