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?

Members fund testing for the Drupal project. Drupal Association Learn more


stella’s picture

Status: Active » Fixed


comat0se’s picture

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.

stella’s picture

Status: Active » Postponed (maintainer needs more info)

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

dokuf’s picture

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.

palamida’s picture

Version: 6.x-1.10 » 6.x-1.11
53.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 ?>]" ....


<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)

comat0se’s picture

Status: Postponed (maintainer needs more info) » Active

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

toomanypets’s picture

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

toomanypets’s picture

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.
ergophobe’s picture

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?

ergophobe’s picture

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

ergophobe’s picture

1.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.

- 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.

ergophobe’s picture

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.

toomanypets’s picture

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!

ergophobe’s picture

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

lpalgarvio’s picture

subscribing =P

NPC’s picture

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!

ergophobe’s picture

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.

NPC’s picture

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.

NPC’s picture

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 :(

NPC’s picture

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 :)

sponsch’s picture


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

ergophobe’s picture

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

Sponsch - thanks for the confirmation

Vchris’s picture

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

Magnus’s picture

Status: Reviewed & tested by the community » Needs work
1.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
  • 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:
    when it should be:
  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.

Boobaa’s picture

1010 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.

charles.holtzkampf’s picture

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

Summit’s picture

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:


While it needs to be:

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

gease’s picture

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

giorgio79’s picture


ducdebreme’s picture

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.

portulaca’s picture

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.

Michel Poulain’s picture

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

Tested with :

  • CKEditor
  • Lightbox2 6.x-1.11
  • Insert 6.x-1.1
  • Imagecache 6.x-2.0-beta12
  • Imagefield 6.x-3.10
karensmallwood’s picture

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

hanoii’s picture

Status: Reviewed & tested by the community » Needs review
1.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.

barteque’s picture

Solution #25 saved my day. Thanks!!

femaltol’s picture

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.

FiNeX’s picture

Patch #34 and #25 works fine!

aitala’s picture

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..


bxiong’s picture

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?

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

Coworker logs in (user3).
Creates a new page.
Inserts image with style Lightbox2: thumbnail->original
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?


aitala’s picture

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


bxiong’s picture

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. =/

aitala’s picture

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.


aitala’s picture

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

Go figure.


  • stella committed 4b38869 on 8.x-1.x
    #830092 - download original link for insert module

  • stella committed 4b38869 on 7.x-2.x
    #830092 - download original link for insert module
joseph.olstad’s picture

Version: 6.x-1.11 » 7.x-2.0
Issue summary: View changes
Status: Needs review » Fixed

fixed in 7.x-2.0
if you want this fix then please upgrade to 7.x-2.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.