scaron / prettyphoto

prettyPhoto is a jQuery based lightbox clone. Not only does it support images, it also add support for videos, flash, YouTube, iFrames. It’s a full blown media lightbox. The setup is easy and quick, plus the script is compatible in every major browser.
http://www.no-margin-for-errors.com/projects/prettyPhoto-jquery-lightbox-clone/
553 stars 280 forks source link

Iframe: Filtering "iframe"-Param out of frame_url is very buggy #130

Open typoworx-de opened 11 years ago

typoworx-de commented 11 years ago

PrettyPhoto can be triggered as "iframe" by appending the URL-Param "iframe=true" to the link triggering.

The logic inside PrettyPhoto filtering out this get-param isn't very clean and can lead into a bunch of problems in its current logic:


                case 'iframe':

[...]

                    frame_url = pp_images[set_position];
                    frame_url = frame_url.substr(0,frame_url.indexOf('iframe')-1);

If you have a link like this one you will run into trouble with the logic above: http://www.my-webpage.com/my-iframe.php?test=1&output=iframe&iframe=true

PrettyPhoto will render the link useless as shown below: http://www.my-webpage.com/my-iframe.php?test=1&output=[MISSING]

I have a patch that will fix this issue. Replace the code-line of yours above with this one:

----[ PATCH START ]---- frame_url = pp_images[set_position]; frame_url = frame_url.replace(/[\?&]iframe=(true|1)/,''); ------[ PATCH END ]------

By the way. In common cases it may be useful to keep the iframe/ajax type-param of PrettyPhoto in the URL to render the HTML output matching it's target intense (AJAX without HTML-Header or IFRAME with HTML-Header).

I would also prefer to be able to use the iframe/ajax trigger with "true" and "1" as value. The usage of "true" isn't very common.