NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item11383 for general documentation changes for release 1.1.5. Use Item9693 for docu changes for release 2.0.

Item1813: ImageGalleryPlugin gets confused by images carrying same name

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Urgent Waiting for Feedback Extension ImageGalleryPlugin Main.MichaelDaum

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

ItemTemplate edit

Summary ImageGalleryPlugin gets confused by images carrying same name
ReportedBy PhilippLeufke
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component ImageGalleryPlugin
Priority Urgent
CurrentState Waiting for Feedback
WaitingFor MichaelDaum
Checkins Foswikirev:7320 Foswikirev:7321
TargetRelease n/a
ReleasedIn
Topic attachments
I Attachment Action Size Date Who Comment
item1813.patchpatch item1813.patch manage 12.9 K 26 Apr 2010 - 20:07 ItaloValcy  
Topic revision: r8 - 15 May 2010 - 01:12:41 - GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads