Piwigo / piwigo-openstreetmap

OpenStreetMap integration for Piwigo
http://piwigo.org/ext/extension_view.php?eid=701
GNU General Public License v3.0
35 stars 35 forks source link

Thumbnail not displayed on OSM-Map if filename contains more than one dot (.) #68

Open jheinitz opened 8 years ago

jheinitz commented 8 years ago

Hello,

first of all, I would like to thank you for your great work. This is really cool stuff.

I found an issue with some of my pictures. They are not beeing displayed on the OSM-Map when I point on the blue marker. First I thought that it is related to my german "Umlaute" like äöü. but it is not. I figured out that a picture called "TestPicture_03.09.2015.jpg" is not shown. In the i.log I can see that a requst is made to "TestPicture_03-sq.jpg". As you can see the ".09.2015" is missing.

Any ideas? If you point me to the right direction, I can try to fix it on my own.

By the way, the pictures do show up in the standard piwigo albums.

Thanks and kind regards

Jens

xbgmsharp commented 8 years ago

Hello, It is a know issue. This issue has been raise before. You can find a workaround by referring to issue #60. It is not implemented yet, as it make an assumption that I don't really like. Let me know if it works for you, so I can push a patch.

jheinitz commented 8 years ago

Hello,

thanks for the quick reply. I tried the workaround from issue #60 but it did not help for me. I think that this is due to the fact that my directory does not contain one or more dots, but the filename itself.

However, I played around with it and found a solution. I replaced the L191 with the following code:

concat(trim(both '.' from reverse(substr(reverse(i.path),instr(reverse(i.path), '.'),255))),'-sq.',SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', -1 )), -- trim(leading '.' from concat(trim(trailing '.' from left(i.path, length(i.path) - instr(reverse(i.path), '.'))),'-sq', right(i.path, instr(reverse(i.path), '.')))),

Maybe a little bit hard to read, but let me explain what I achieved using this SQL code:

  1. I look for the first occurence of a dot in the reverse string of i.path [instr(reverse(i.path))]
  2. then I select the substring of the reverse string for i.path from the first occurence of the dot to the end [substr(reverse(i.path),instr(reverse(i.path), '.'),255)]
  3. then I perform another reverse() my string [reverse(substr(..........))]
  4. Now I remove the leading and the trailing dot from the string [trim both '.' from (....)]
  5. Then I add the string '-sq.' to my string using concat()
  6. In the same concat I add the extention of the file which I find using right() and instr() [right(i.path, instr(reverse(i.path), '.'))]

I can confirm that this works with filenames containing a single dot or up to 5 dots. It is also working when the i.path contains special characters like german Umlaute (äöüß).

Maybe this can be included in one of the next releases.

Thanks and kind regards

Jens