forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: flapane on January 01, 2015, 04:39:19 pm

Title: Empty spaces inside photo's description textfield.
Post by: flapane on January 01, 2015, 04:39:19 pm
I noticed that if I upload some photo and then add a description, the description text field contains 31 empty spaces which must be manually deleted.
I couldn't find any setting where to set the default text of the photo's description, nor Firebug or theme.php seem to help.
Any hints?
Thank you and happy new year
Title: Re: Empty spaces inside photo's description textfield.
Post by: Αndré on January 01, 2015, 08:52:26 pm
I cannot replicate that issue in my testbed. Maybe the description has automatically be imported by IPTC data?
Title: Re: Empty spaces inside photo's description textfield.
Post by: flapane on January 01, 2015, 10:07:37 pm
Ugh, that's interesting: it looks like that Photoshop CS5 is somehow adding those spaces in the description field. It doesn't happen if I resize the photo with another software.
It didn't happen with my previous Nikon D80 camera nor it happens with a Samsung S4 Mini.
It seems that the issue occurs when editing JPG files produced by a relatively recent Sony A6000 camera.
What's even stranger is that Windows 7 x64 doesn't show such empty spaces in "file properties --> desciprition".

It doesn't happen if I upload an untouched 24Mpix A6000 JPG file, so it's definitely Photoshop CS5's fault.

I may disable IPTC data import feature, given that I don't insert location/title/keywords in the JPG file.
Otherwise, if you want I can attach an A6000 jpg file, and if it turns out that it happens with more recent versions of Photoshop, an exception for A6000 desciprion field could be added to cpg source code.
Title: Re: Empty spaces inside photo's description textfield.
Post by: Αndré on January 01, 2015, 10:28:42 pm
Open include/picmgmt.inc.php, find
Code: [Select]
                $title = (isset($iptc['Headline'])) ? $iptc['Headline'] : $title;
                $caption = (isset($iptc['Caption'])) ? $iptc['Caption'] : $caption;
and replace with
Code: [Select]
                $title = (isset($iptc['Headline'])) ? trim($iptc['Headline']) : $title;
                $caption = (isset($iptc['Caption'])) ? trim($iptc['Caption']) : $caption;

This should fix the issue for future uploads. It's maybe a good improvement for the core code, so please confirm if it works as expected.
Title: Re: Empty spaces inside photo's description textfield.
Post by: flapane on January 03, 2015, 10:19:36 pm
trim() does the trick, so I can confirm that it fixes the issue.

As usual, thanks for your help!
Title: Re: Empty spaces inside photo's description textfield.
Post by: Αndré on January 08, 2015, 10:43:05 pm
Committed in SVN revision 8757. Will be part of cpg1.5.36 and later.