1. Add new Image node
2. Give it a title and browse for an image and submit (image01 using image01.jpg)
3. Add a new Image node
4. Give it a title and upload a new image with the same file name as the previous (image01 using image01.jpg <-- different image)
5. ---> In your images folder only a image01_0.jpg image is created with no thumbnail or preview

Is this intended functionality?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drewish’s picture

i can confirm that is a bug

drewish’s picture

Status: Active » Needs work
FileSize
9.6 KB

please test out the attached patch. i don't think it's quite ready yet but it's close

theiviaxx’s picture

No dice. It is still just making an Image_0.jpg. I have been looking at it and i can't figure out where it's is creating those files. It seems, you need to make the incremental original, i.e. Image_0.jpg, first, then pass that into the sizes functions.

drewish’s picture

were you uploading a new file? try deleting the existing image nodes and their files, then put in two new files of the same name. you should get image.jpg and image_0.jpg (as well as all the image.*.jpg and image_0.*.jpg files). if you're not getting the resized images you've probably run into http://drupal.org/node/130473

theiviaxx’s picture

I've tried from scratch with the same outcome. I will check out the other issue. I am also using that patch someone wrote for saving in user folders which may be the cause of it.

It's wierd, right now if i add image 1, then add image 2, only image_0.jpg gets made. But the node is using image.preview.jpg for it's preview image. I thought it odd that it would associate a different preview/thumbnail file with image_0.jpg. I if use print_r($node) to see what in there, if get:

[images] => Array
        (
            [_original] => files/users/XXX/Image_0.jpg
            [thumbnail] => files/users/XXX/Image.thumbnail.jpg
            [preview] => files/users/XXX/Image.preview.jpg
        )
theiviaxx’s picture

Also, i fi edit the node using Image_0.jpg and change nothing, then save ('update'), it removed Image.preview.jpg and image.thumbnail.jpg and copies in Image_0.preview and Image_0.thumbnail.jpg. Then if i view the node using Image.jpg, it will then create Image.prewvie.jpg, etc. So in essence to get everything to work right, I have to:

1. Add a node with Image.jpg -- Node1
2. Add a new node with Image.jpg again -- Node2
3. Edit Node2 and save
4. View Node1

I hope this helps you drewish. I will keep looking at it as well.

Thanks

drewish’s picture

humm, please give it a try without the other patch. once this is working i'd like to start trying to get dman's patch on #103793 working and committed. it makes the image paths configurable.

theiviaxx’s picture

I started from a new copy of image.module, then applied the patch. It still does the same thing.
Here is what happens:

Image1 and Image2 are different images and share the same name (image.jpg);

1. Create image node and use image.jpg(Image1)
2. Create image node and use image.jpg(Image2)
3. Image2 will be created as image_0.jpg
4. In the images folder, there is now image_0.preview.jpg and image_0.jpg (Correctly rendered);
5. In the Temp folder, there are Image2's preview and thumbnail sizes, but they are named as image.xxx.jpg not image_0.xxx.jpg
6. Image node 2 using Image2 uses image.preview.jpg <-- Is the Image1 preview image

So i guess this narrows down the DB entries? As the Image1 images are incorrectly being associated with the Image2 node?

I hope the above is clear. Theres a lot going on with this module.

drewish’s picture

been doing some more testing... try this for me. open up each node, edit it, don't make any changes but just save it. go back in and look at the edited node, all the files are right now aren't they?

yeah it's still broken when you upload a file bug as soon as it's re-saved, it seems to straighten itself out...

drewish’s picture

Status: Needs work » Needs review
FileSize
10.26 KB

okay, i think i've gotten it figured out. please try out this patch.

theiviaxx’s picture

Confirmed working. I just did a simple test (adding one image, then another with the same name) and it created all originals and sizes properly. Thanks drewish!

drewish’s picture

Status: Needs review » Reviewed & tested by the community

cool, i want to give walkah a chance to look at it before i commit this

drewish’s picture

Status: Reviewed & tested by the community » Fixed

i went ahead and committed this.

oadaeh’s picture

After spending a couple of hours on this problem this morning (I didn't find this issue during my searches :^(), it seems to me the patch is way overkill, and a simple change to one line of code will fix the problem (it did for me).

In the image.module file of the official 5.x download (http://ftp.osuosl.org/pub/drupal/files/projects/image-5.x-1.0.tar.gz), change line 297 from

  _image_build_derivatives($node, FALSE);

to

  _image_build_derivatives($node, TRUE);

What happens is that at the time of submitting the image node, the temporary copies of the preview and thumbnail images are first deleted from the temp directory and then recreated in the permanent directory. Later on, a file_move operation is called (which calls file_copy) with the source and destination paths of the derivative files being the same. Because those paths are the same, file_copy does nothing.

The derivative files need to be recreated (if that delete and recreation part is even necessary) in the temp directory so that the file_copy operation will complete normally, including the renaming of the files.

drewish’s picture

there is some other code clean up in there (the module could still use quite a bit more) but the real meat of the patch is that _image_insert() needs to take the $node by reference so that if the original file gets renamed all the derivative images are renamed accordingly.

by all means if you think there's too many files being created and deleted (and i'm sure there are) grab the new release, cut down on those, and roll a patch. i'd love the help.

Anonymous’s picture

Status: Fixed » Closed (fixed)
loopy1492’s picture

Version: 5.x-1.0 » 7.x-1.x-dev
Status: Closed (fixed) » Active

This is happening in Drupal 7. I delete an image, then upload a new one with the same name, and the old one shows up in its place in my views and pages, even after clearing caches several times.

joachim’s picture

Version: 7.x-1.x-dev » 5.x-1.0
Status: Active » Closed (fixed)

Please report that in Drupal core -- it's nothing to do with this project.