[In version 5.8] Issue with lightbox code

If you've programmed a new HuMo-genealogy feature (that you'd like to see included in the official version), please upload and describe your work here.
Post Reply
colin
Posts: 48
Joined: Sun 24 Dec 2017, 23:13

[In version 5.8] Issue with lightbox code

Post by colin »

Yoshi & Huub,

I've found an issue with the lightbox display of the text under the image.
The issue only occurs when there are multiple lines in the text to be displayed, and, I believe, easily fixed with a simple (hopefully) adjustment in the gedcom import.

When importing the gedcom tag 'TITL', there can be (and I have quite a lot) where there is a following 'CONT' tag to add an extra line (or lines). When imported into the database, these are being separated by a crlf, which, on the surface, seems t be fine.
However, when the code for lightbox is generated, the description text includes these crlf's. However, lightbox doesn't like this, and doesn't display any text under the image.
I believe the fix (I'll be testing it later today by editing my gedcom file & reloading the database) is to, instead of having a crlf between the TITL & CONT, and then between any further CONT tags, is to use the html <br> tag, so we don't 'break' the code to lightbox with crlf's, but retain the text going onto the following line. (Expect this to be an easier fix than finding every reference to this text & modifying it on the fly for use in lightbox - and it shouldn't impact displaying the text on any page as well).

Colin
colin
Posts: 48
Joined: Sun 24 Dec 2017, 23:13

Re: Issue with lightbox code - potential fix in gedcom import

Post by colin »

Just checked, and changing the date to have the <br> instead of the crlf when storing the TITL/CONT/CONt works perfetly, and displays the text correctly, preserving the new lines in the output
User avatar
Huub
HuMo-genealogy programmer
HuMo-genealogy programmer
Posts: 2692
Joined: Wed 27 Aug 2008, 11:34
Location: Heerhugowaard, Netherlands
Contact:

Re: Issue with lightbox code - potential fix in gedcom import

Post by Huub »

I believe the fix (I'll be testing it later today by editing my gedcom file & reloading the database) is to, instead of having a crlf between the TITL & CONT, and then between any further CONT tags, is to use the html <br> tag, so we don't 'break' the code to lightbox with crlf's, but retain the text going onto the following line. (Expect this to be an easier fix than finding every reference to this text & modifying it on the fly for use in lightbox - and it shouldn't impact displaying the text on any page as well).
Thanks for checking this problem! I allready noticed it, but didn't checked it yet. I didn't know the crlf was the problem!
It's better to change the text with every lightbox item, because I never store HTML items in the database. If there are HTML codes in the database, they will be exported in a GEDCOM export. And it's just not official GEDCOM code anymore. It could also be a problem in PDF and RTF export.
There is another reason not to do this in GEDCOM import: several users use the editor in HuMo-genealogy. So it's needed to do this in the photo scripts.

Maybe use the HuMo-genealogy function process_text() or use PHP nl2br or PHP htmlentities.
There are only two files where GLightbox is generated:
include/show_picture.php
photoalbum.php.

It's this line in the scripts:

Code: Select all

echo '<a href="'.$dir.$filename.'" class="glightbox3" data-gallery="gallery1" data-glightbox="description: '.str_replace("&", "&amp;", $picture_text2).'">';
I have tried this code (using htmlentities) but it doesn't work:

Code: Select all

echo '<a href="'.$dir.$filename.'" class="glightbox3" data-gallery="gallery1" data-glightbox="description: '.htmlentities($picture_text2).'">';
I also tried all these options (str_replace, htmlentities, nl2br), but not succesful so far:

Code: Select all

$picture_text2=str_replace(array("\\r\\n", "\\r", "\\n"), "<br />", $picture_text2);
$picture_text2=htmlentities($picture_text2);
$picture_text2=nl2br($picture_text2);
echo '<a href="'.$dir.$filename.'" class="glightbox3" data-gallery="gallery1" data-glightbox="description: '.$picture_text2.'">';
Frustrating, I can't solve this at this moment... (there could be a difference in Windows and Linux server settings) :geek:
I will check this later, I have some other items I want to solve first.
HuMo-genealogy update? Backup your database! Editing in HuMo-genealogy? Backup your data!
Make multiple backups with: PHPMyAdmin, gedcom export and database export.

HuMo-genealogy software: http://humo-gen.com
User avatar
Huub
HuMo-genealogy programmer
HuMo-genealogy programmer
Posts: 2692
Joined: Wed 27 Aug 2008, 11:34
Location: Heerhugowaard, Netherlands
Contact:

Re: Issue with lightbox code - potential fix in gedcom import

Post by Huub »

I probably found the solution, I didn't use the correct GLightbox options to show HTML codes. Glightbox uses a seperate <div> to show the HTML codes.

Replace this code:

Code: Select all

echo '<a href="'.$dir.$filename.'" class="glightbox3" data-gallery="gallery1" data-glightbox="description: '.str_replace("&", "&amp;", $picture_text2).'">';
In file photoalbum.php:

Code: Select all

echo '<a href="'.$dir.$filename.'" class="glightbox3" data-gallery="gallery1" data-glightbox="description: .custom-desc'.$picture_nr.'">';
echo '<div class="glightbox-desc custom-desc'.$picture_nr.'">'.$picture_text2.'</div>';
In show_pictures.php:

Code: Select all

$picture='<a href="'.$picture_array['path'].$picture_array['picture'].'" class="glightbox3" data-gallery="gallery'.$event_connect_id.'" data-glightbox="description: .custom-desc'.$media_event_id[$i].'">';
$picture.='<div class="glightbox-desc custom-desc'.$media_event_id[$i].'">'.$title_txt.'</div>';
I will add these changes in the next version!
HuMo-genealogy update? Backup your database! Editing in HuMo-genealogy? Backup your data!
Make multiple backups with: PHPMyAdmin, gedcom export and database export.

HuMo-genealogy software: http://humo-gen.com
colin
Posts: 48
Joined: Sun 24 Dec 2017, 23:13

Re: Issue with lightbox code - potential fix in gedcom import

Post by colin »

Thanks Huub.
I'll check first chance I get - just home from major surgery - so not in a state to do much at the moment.

Colin
User avatar
Huub
HuMo-genealogy programmer
HuMo-genealogy programmer
Posts: 2692
Joined: Wed 27 Aug 2008, 11:34
Location: Heerhugowaard, Netherlands
Contact:

Re: Issue with lightbox code - potential fix in gedcom import

Post by Huub »

Hi Colin,

I hope you're fine now!

The lightbox script is improved in HuMo-genealogy version 5.8.
HuMo-genealogy update? Backup your database! Editing in HuMo-genealogy? Backup your data!
Make multiple backups with: PHPMyAdmin, gedcom export and database export.

HuMo-genealogy software: http://humo-gen.com
colin
Posts: 48
Joined: Sun 24 Dec 2017, 23:13

Re: [In version 5.8] Issue with lightbox code

Post by colin »

Thanks :)

Going to take a while - was major surgery on my cervical spine :(

I've upgraded - but need to reload my data as I'd changed all the crlf to <br> - so need to reverse that.

(Found a new bug in latest - I'll put up a post on it seperately)

Colin
Post Reply