Item1813: ImageGalleryPlugin gets confused by images carrying same name
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release: n/a
Description
When creating a gallery from several topics (like e.g. the built-in
UserListByPhotograph),
ImageGalleryPlugin is confused, if two images carry the same name. It will just display one of the pictures as thumbnails and in the enlarged view. Only clicking the latter will forward you to the right picture.
The problem is, that the thumbnail and the URL for the enlarged view only encode the file name and not the original topic (where the file is attached) as additional parameter, which in my eyes is needed for non-ambiguous linking.
I'm pretty sure that
Item1587 is related to this issue.
Setting the priority to
urgent since this affects the built-in
UserListByPhotograph and it's generally quite likely, that two topics contain images with the same file names.
BTW: Is the following a bug or a feature?
When the
comment
of a picture is set to e.g.
photo of %TOPIC%
and the comment is included into
title
or
thumbtiltle
, then the %TOPIC% macro expands to the name of the topic where the image gallery is created.
- Is there a workaround?
- Is this problem related to the abovementioned issues?
- Shall I open a new bug for this?
--
PhilippLeufke - 08 Jul 2009
Anybody???
--
PhilippLeufke - 26 Aug 2009
No-one???
--
PhilippLeufke - 08 Sep 2009
I think I can help in this task. I've tested the scenario reported by Philipp and I confirm the bug.
The problem seems to be related with the IGP's cache: "Images and thumbnails are resized according to the given settings and are cached thereafter.". To manage this cache, IGP creates a "repository" in
%PUBURLPATH%/images/%WEB%/%TOPIC%/ID/
and store all images from the topics list (
topic
argument of %IMAGEGALLERY%). Then, IGP uses this cache to display images in the gallery. But, we can have images with the same name and this causes an overwrite...
An ideia to solve this problem could be join the
original web and
original topic with the image name in cache. Thus, I think the following patch could help (from
http://svn.foswiki.org/trunk/ImageGalleryPlugin).
Index: lib/Foswiki/Plugins/ImageGalleryPlugin/Core.pm
===================================================================
--- lib/Foswiki/Plugins/ImageGalleryPlugin/Core.pm (revision 7203)
+++ lib/Foswiki/Plugins/ImageGalleryPlugin/Core.pm (working copy)
@@ -636,6 +636,9 @@
next;
}
+ # rewrite the image name to avoid overwrite
+ $image->{name} = $theWeb . '_' . $theTopic . '_' . $image->{name};
+
push @images, $image;
}
}
Enviroment test:
- display current topic attachments
- display other topics attachments (which have images with the same name)
- clicking on a thumbnail should zooms the image
- use custom format argument
- delete a image of the original topic should delete the image from gallery topic
- test the refresh query parameter
--
ItaloValcy - 21 Apr 2010
Philipp, about your last question on previous post, IMO it is not a bug. I think you should use %BASETOPIC% instead of %TOPIC%. More info:
VarBASETOPIC.
--
ItaloValcy - 21 Apr 2010
Talking to
MichaelDaum, he proposed another solution (the right solution):
[18:59] <MichaelDaum> okay now here's what the ideal solution would be:
[19:00] <MichaelDaum> the thumbnail of an image attached to web_a/topic_a is always located at pub/images/web_a/topic_a
[19:00] <italovalcy> I'm listening
[19:00] <MichaelDaum> that is the thumbnail directory depends on the location of the original image, not the topic where an imagegallery is shown.
[19:01] <MichaelDaum> further more, thumbnail names should encode its size
[19:01] <MichaelDaum> something like thumnail_130_190_image-name.png
[19:01] <italovalcy> ok
[19:02] <MichaelDaum> the reason for this is that thumnails should be reused as much as possible
[19:02] <italovalcy> make sense
[19:02] <MichaelDaum> let's say two imagegalleries trigger thumbnails of an image at a distant topic
[19:02] <MichaelDaum> they might or might not show thumbnails of the same size
[19:03] <MichaelDaum> further more ImagePlugin should use pub/images/web/topic as well ... and use the same thumbnail naming scheme
[19:04] <MichaelDaum> as you sense, this needs more code changes than you nice patch
[19:04] <MichaelDaum> I'd normally favor a min-change-patch that fixes the error
--
ItaloValcy - 21 Apr 2010
I've worked in this task the last days and I think that I've a patch that solve the problem according to
MichaelDaum's proposal. The patch is
attached in this topic. Michael, could you please review my patch?
--
ItaloValcy - 26 Apr 2010
I changed the task to Waiting for Feedback from
MichaelDaum - so that he will see you are waiting for a review.
--
GeorgeClark - 15 May 2010
This is still an issue; I tried
ItaloValcy's patch but I got this error:
Error: Exception 435: unable to open image `/foo/bar/foswiki/pub/images/Web/SubWeb/00082/thumb_167x95_image001.jpg': @5o—ÿ @ error/blob.c/OpenBlob/2489
--
PaulHarvey - 10 May 2012 - 00:46
Still not fixed...
--
PhilippLeufke - 26 May 2013
Please check the latest release and reopen if it still not fixes the issue reported here. Thumbnails are generated by
ImagePlugin now and thus follow a different naming strategy all together.
--
MichaelDaum - 27 Jul 2017