I have tried to put "Download original" link in lightbox for images inserted via Insert module. I have edited lightbox2-insert-image.tpl.php but problem is that all html is filtered, eg. "<: becomes "<" and so on.

Something like this:

<a rel="lightbox[group1][__description__][<a href="<?php print $linkurl ?>">Download original</a>]  href="<?php print $linkurl ?>"><img src="<?php print $url ?>" alt="__alt__" title="__title__" class="imagecache-<?php print $image_preset_name ?><?php print $class ? ' ' . $class : '' ?>" /></a>

How to make it work? Can you do that in future version?

Comments

Status:Active» Fixed

committed

Version:6.x-1.x-dev» 6.x-1.10
Component:User interface» Code
Category:feature» bug
Status:Fixed» Active

lightbox2-insert-image.tpl.php seems to be broken... as of 1.10 it's inserting a malformed link into the body.

Status:Active» Postponed (maintainer needs more info)

Can you provide more info or a link to the site?

Yepp, I can confirm this.

I had to disable 'Download original' to get inserting via insert module working again, otherwise I get inserted something like below:

<a href="http://...link to image..." target="_blank" id="lightbox2-download-link-text" rel="lightbox[group1][DESCIPTION&lt;br &gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=">Download Original</a>]" href="http://...link to image..."&gt;<img src="http://...link to image..." alt="ALT" title="TITLE" class="imagecache-bild_node">

I have this issue with 1.11.

Version:6.x-1.10» 6.x-1.11
StatusFileSize
new53.42 KB

Using Insert 1.0-beta6 and Lightbox2 1.11 caused the problem to me, too

Broken markup was generated

To solve the problem (for now) I disabled the download original link in Lightbox2 by editing the lightbox2-insert-image.tpl.php
from the original:

<a rel="lightbox[group1][__description__<?php print $download_link ?>]" ....

to

<a rel="lightbox[group1][__description__]" ....

You can see the broken markup in the screenshot (there should be only the image with the link to lightbox and no text at all)

Status:Postponed (maintainer needs more info)» Active

It's attempting to nest quotes... generating the $download_link inside of the original rel=" set.

This appears to be related to, or perhaps duplicate of, #929720: Mangled HTML when using Lightbox2 Insert Preset.

As a work-around until this issue is addressed, without hacking the code, you can set the "Text for image original link:" to blank under Text Settings on admin/settings/lightbox2.

This is the text that will appear as the link to the original file underneath the image in the lightbox. Leave this blank for the link not to appear. It will only appear for images uploaded via the "image" or "imagefield" modules. Users will need the "download original image" permission, but also the "view original images" permission if using the "image" module.

There are a couple of issues here with the way the download_link is formed in template_preprocess_lightbox2_insert_image in lightbox2.insert.inc

1. The download_link for "Download Original" is not created correctly. It is using the image_cache preset but it is supposed to link to the original. That's easy to patch, but I'm holding off because of issue #2

2. The download_link is getting double encoded as entities. So while in a normla lightbox2 link it would be something like
&lt;br /&gt;

as put into the hidden field in insert, it's getting out as
&amp;lt;br /&amp;gt;

I've tried to reverse this for experimenting by changing the template file to print decode_entities($download_link) but to no avail and am tearing my hair out over this. I've tried this with an input format with all filters turned off and I just can't seem to get the encoding to come out right.

Any ideas?

I have this fixed. I'll upload a patch in a few minutes.

StatusFileSize
new1.09 KB

Okay, so here's the patch. It has only been tested on one install, but it seems to be working okay. Please test.

Limitations:
- The Imagefield version shows a default description based on node title, but this only shows a description if you actually have one in the description field, which, honestly seems better anyway.
- This has only been tested with an input format that does no filtering. If you have a wysiwyg editor or anything like that, who knows what will happen? I don't anyway.

What this patch changes
- adds a new variable: $linkpath_original. The original version was using the imagecache version here, but since this is the Download Original link, it needs to remember the original filepath, not the imagecache preset that is shown in the lightbox. Also, the $linkpath variable is getting run through insert_create_url() but that seems to create issues, so $linkpath_original is not.

- convert $vars['download_link'] to HTML entities. Essentially, the html in the Lightbox rel attribute needs to be double encoded. It gets decoded once when it gets inserted into the textarea and now it works. However, I don't know if wysiwyg editors will decode again or anything weird like that.

Patch attached.

Status:Active» Needs review

Okay, I've tested this using TinyMCE with the Full HTML input format and it works fine.

So if someone else can test this on their install, perhaps we can mark this reviewed and tested and ask Stella to commit it.

Manually applied patch#11 to Lightbox2 6.x-1.11. Running with Insert 6.x-1.0-beta6 and ImageCache 6.x-2.0-beta10. Set "Text for image original link:" to "Download This Big Image" under Text Settings on admin/settings/lightbox2. Then inserted a small imagecached version of the image with a Lightbox2 large display.

No problems. Looks great. Thanks ergophobe!

Status:Needs review» Reviewed & tested by the community

It's such a small change, I'm going to update this to reviewed and tested, but it would be nice to get one more test!

Thanks for your test TMP

subscribing =P

Hi ergophobe!

I've tried your patch from #11, with TinyMCE (wysiwyg editor) and Filtered HTML, and inserting doesn't do anything for me - I press the button, nothing happens.

Trying to remove your changes one by one, I see that if I don't include the htmlentities call, then it inserts the wrangled mass of HTML code for me (but I guess it may be different for others, depending on their Lightbox2 config):

<a href="link_to_orig_image" target="_blank" id="lightbox2-download-link-text" rel="lightbox[group1][&lt;br &gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=">Download the original image</a>]" href="link_to_orig_image"&gt;<img src="link_to_imagecache_image" alt="Image" class="imagecache-Colx1">

(no trailing "a" tag in additional to the craziness) Do you have ideas why htmlentities could stop Insert from working altogether? May be I have a different issue (though it looks very similar to the one discussed here)? Do I need the dev version of Lightbox2 for this? I am using 1.11, as by the dates they look the same to me.

Thanks for your help with this!

There's no real difference between the 1.11 version and the dev version at this point (I did a full diff to verify).

Can you try it with full HTML and without TinyMCE and start from there to see if *that* works. By default, Filtered HTML does NOT allow the img tag, so that's going to get stripped on output. So it doesn't matter how well Insert and Lightbox2 and TinyMCE work together, if you are using default settings for Filtered HTML, nothing's going to happen.

I have allowed img for filtered HTML, and insert did work before I updated to latest Lightbox2 (I was on dev version before, specifically for Insert to work with Lightbox2 presets) - though I didn't notice that immediately, so may be something else caused it.

I will try with Full HTML, though.

The insert button doesn't do anything on Full HTML, with the WYSIWYG turned off (I deleted the editor profile for the Full HTML mode). I hope I am not the only one having this, as then the chances of it being fixed are slim :(

For me it works for both filtered and full HTML modes if I remove the htmlelements call, and, in the resulting HTML, replace the double quotes with single quotes in the link that's included in the "rel". Then the quote doesn't close prematurely, and the insertion works fine.

Thus I replaced the htmlelements call with a str_replace call on the "l" function, and the code looks like this:

$vars['download_link'] = '<br /><br />' . str_replace('"', '\'', l($download_link_text, $linkpath_original, array('attributes' => array('target' => '_blank', 'id' => 'lightbox2-download-link-text'))));

It works for me in both Full and Filtered HTML modes, with and without the WYSIWYG editor! Thanks for your help :)

Hello,

I applied the patch #11 and it works good. Using FCKeditor 2.6.5; imagecache 6.x-2.0-beta10, Lightbox2 6.x-1.11. It works in Full and Filtered HTML modes.

Thanks for the patch

NPC - sorry, I haven't had time to test, but I'll try to look into it soon.

Sponsch - thanks for the confirmation

The solution that NPC provides above works fine for me. Thanks!

Status:Reviewed & tested by the community» Needs work
StatusFileSize
new1.02 KB

Neither of the solutions works for me, but the proposed change by NPC makes it a little better. Attached is a patch based on NPC's suggestion.

Installed modules:

  • Lightbox 6.x-1.11 (with this patch)
  • 6.x-1.0-beta6
  • Wysiwyg 6.x-2.x-dev
  • TinyMCE 3.3.9.2
  • ImageCache 6.x-2.0-beta10
  • Filefield Sources 6.x-1.2

I use private filesystem and sometimes I have a userreference in the node. I have tried to switch of WYSIWYG and used Full HTML, but I get the same results

  1. The formating of the userreference breaks, and all blocks on the righhanded sidebar (my theme is a custom Garland theme) gets relocated to the bottom of the page.
  2. The link to the original file becomes relative to my servers root, and not to my site:
    //home/myaccount/private_files/images/myimage.jpg
    when it should be:
    mydomain.org/system/files/images/myimage.jpg
  3. When I upload an image to the server and try to insert it, it doesn't work righ away. I have to save the node first and then insert the image.

If I use Colorbox module and insert a Imagefield everything works as supposed so this got to be a bug in Lightbox.

StatusFileSize
new1010 bytes

Having almost the same stuff (drupal-6.20, lightbox2-6.x-1.11 with this patch, wysiwyg-6.x-2.2, ckeditor-3.4.2, imagecache-6.x-2.0-beta10, imagefield-6.x-3.9) and the same error, I had to face the fact that the patch in #24 contains DOS line endings (or something else), so it does not apply.

Here is the rerolled patch, which does work well for me.

I add the same problem and patch #25 worked for me. I am still however getting the issue in IE9, any ideas ?

Hi,
I applied patch #25, but no go (Ubercart2/Drupal6/Lightbox2 latest).
When I upload images with imagecache (and lightbox2 enabled), the link to the image becomes something like:

/sites/default/files/imagecache/product/sites/default/files/imagefield_default_images/IMAGE.jpg

While it needs to be:
/sites/default/files/imagecache/product/IMAGE.jpg

I also have fckeditor latest version on the page.

EDIT: Reading more about this stuff the link is fine! It was another problem what I had.
greetings, Martijn

Confirm that patch #25 solves the issue. What is reported in #27 seems to be a different issue, and more likely related to imagecache.

+1

Confirmed that patch #25 solves the issue with lightbox2 6.x 1.11
But the patch does NOT YET seem to be included in lightbox2 6.x-dev.

Status:Needs work» Reviewed & tested by the community

I can also confirm that the patch from #25 fixes the formatting issue on imagefield.

Tested on Lightbox2 6.x-1.11, Insert 6.x-1.1, Imagecache 6.x-2.0-beta10, Imagefield 6.x-3.10.

Great work Booba. Your patch #25 works for me too.
Thanks a lot. Hope this patch will be committed.

Tested with :

  • CKEditor 3.3.1.5586
  • Lightbox2 6.x-1.11
  • Insert 6.x-1.1
  • Imagecache 6.x-2.0-beta12
  • Imagefield 6.x-3.10

Thanks @Boobaa. Patch #25 works for me too.

Tested with:

Lightbox 2 6.x-1.11
Insert 6.x-1.1
CKEditor 6.x-1.5
ImageCache 6.x-2.0-beta12
Image Field 6.x-3.10

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new1.14 KB

After debugging for quite some time, got to a fix similar to this and landed to this issue. Was hard to pinpoint where to look.

I took a different approach and is to use check_plain() which is the same that happens on the normal formatter.

Attached is my patch. Appreciate some testings even for those you have it already working.

Solution #25 saved my day. Thanks!!

I can assert that with:

CKEditor 6.x-1.8
ImageCache 6.x-2.0-beta12
ImageField 6.x-3.10
Insert 6.x-1.1
Lightbox2 6.x-1.11

both the patches on post #24 by Magnus rerolled by Boobaa on post #25 with changed line endings and the patch on post #34 by hanoii worked for me and solved the issue here. In the end I decided to go with the one by hanoii because i thought it was cleaner.

Thanks for all the involved.

Patch #34 and #25 works fine!

Has anyone noticed any issues with the new version of Insert 6.x-1.2? Its looking like relative paths are not working... nor are absolute ones..

Eric

I applied patch #25 and #34. Both seem to work fine when testing using my user account (user2). When my colleague tests it with her account (user3), it fails. I then test it with Drupal User 1 and it also fails. Anyone else experience this or have a solution?

Steps:
Run patch.
Log in as me (user2).
Create a new page.
Insert image with style Lightbox2: thumbnail->original
Save.
Works - woohoo.

Coworker logs in (user3).
Creates a new page.
Inserts image with style Lightbox2: thumbnail->original
Save.
Fails - we get the garbage extra html code spitting out.

Using Patch #25, here's what the source code looks like.

For me:

<p><a href="/sites/files/image008_0.jpg" rel="lightbox[group1][__description__&lt;br &gt;&lt;/a&gt;&lt;br /&gt;&lt;a href='/sites/files/image008_0.jpg' target='_blank' id='lightbox2-download-link-text'&gt;Download Original&lt;/a&gt;]"><img src="/sites/files/imagecache/thumb/image008_0.jpg" alt="" class="imagecache-thumb imgborder-right"></a></p>

For coworker:

<p><a href="/sites/files/image008_0.jpg" rel="lightbox[group1][__description__<br ></a><br /><a href='/sites/files/image008_0.jpg' target='_blank' id='lightbox2-download-link-text'>Download Original</a>]"><img src="/sites/files/imagecache/thumb/image008_0.jpg" alt="" class="imagecache-thumb imgborder-right"></a></p>

Any ideas why adding the same image using separate accounts creates different code?

Thanks.

I will bet that one of you is on a Mac and one on a PC....

Eric

Thanks for the response.

My coworker is a designer but she's also on a PC.
I know O.O

It seems to be something with the different users. I was able to recreate the error by logging as Drupal User 1. On my account, user2, it seems to work fine. =/

What confuses me is that when I do an insert from my Mac using Safari as user 1, I get,

<a href="/sites/default/files/imagecache/review_cover_full/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" rel="lightbox[field_review_images][TEST&lt;br /&gt;&lt;br /&gt;&lt;a  data-cke-saved-href='/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg' href='/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg' target='_blank' id='lightbox2-download-link-text'&gt;Download Original&lt;/a&gt;]"><img alt="TEST" class="inline-review-image imagecache-inline_image_thumb caption" src="/sites/default/files/imagecache/inline_image_thumb/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" style="margin: 5px; float: left;" title="TEST"></a>

Now on Win7 using IE10 as user 1, I get,

<a href="/sites/default/files/imagecache/review_cover_full/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" rel="lightbox[field_review_images][TEST<br /><br /><a  data-cke-saved-href='/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg' href='/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg' target='_blank' id='lightbox2-download-link-text'>Download Original</a>]"><img title="TEST" class="inline-review-image imagecache-inline_image_thumb caption" style="margin: 5px; float: left;" alt="TEST" src="/sites/default/files/imagecache/inline_image_thumb/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg"></a>

This is in the CKEditor source.

On the rendered output, I see, for the IE10 insert.
<a href="/sites/default/files/imagecache/review_cover_full/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" /><br /><a href='/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg' target='_blank'>Download Original</a>]"&gt;<img title="TEST" class="caption" style="margin:5px; float:left" src="/sites/default/files/imagecache/inline_image_thumb/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" /></a

For the Safari insert, I see,

<a href="/sites/default/files/imagecache/review_cover_full/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" rel="lightbox[field_review_images][TEST&lt;br /&gt;&lt;br /&gt;&lt;a  data-cke-saved-href=&#039;/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg&#039; href=&#039;/sites/default/files/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg&#039; target=&#039;_blank&#039; id=&#039;lightbox2-download-link-text&#039;&gt;Download Original&lt;/a&gt;]"><img class="caption" src="/sites/default/files/imagecache/inline_image_thumb/reviews/t-3476-model-1943-formochka-commander-s-cupola/dragont-3431.jpg" style="margin:5px; float:left" title="TEST" /></a>

Its not an issue with the user account that does the insert either since it happens when I use a non-admin account - its the browser. Always works from a Mac, never seems to work from a PC.

Eric

Addendum - while the insert fails with IE and Firefox on Win7, it does work with Google Chrome.

Go figure.

E