I'm trying to add Lightbox to some anchors on my page, but TinyMCE strips rel="lightbox" as well as class="lightbox".
No HTML filters enabled either in Input format or in WYSIWYG API \ TinyMCE config page.
Page can be saved with Lightbox attributes, but they will be cleared on next edit. Quite anoying.
Possible solution described here: http://drupal.org/node/285270 , but I have no idea how to apply it to WYSIWYG API.
I think Lightbox2 compatibility should be added to the WYSIWYG API core.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blb’s picture

I have had a similar problem where style elements of tags are stripped out. I turned off the "verify HTML" setting under the "cleanup" section of the profile. that seemed to relieve the problem.

however, i would like to be able to use that option and still be able to put in my own styles.

it would be nice to have access to the valid elements list through the interface.

rodrigoaguilera’s picture

in \modules\wysiwyg\editors\tinymce.inc

edit

'advlink' => array(
'path' => $editor['library path'] .'/plugins/advlink',
'extensions' => array('advlink' => t('Advanced link')),
'extended_valid_elements' => array('a[name|href|target|title|onclick]'),
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
'internal' => TRUE,
'load' => TRUE,
),

change it for

'advlink' => array(
'path' => $editor['library path'] .'/plugins/advlink',
'extensions' => array('advlink' => t('Advanced link')),
'extended_valid_elements' => array('a[name|href|target|title|onclick|rel|class]'),
'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
'internal' => TRUE,
'load' => TRUE,
),

I added to the extended valid elements the rel and class atributes

sun’s picture

Status: Active » Needs review
FileSize
957 bytes

Please test attached patch.

sun’s picture

Status: Needs review » Fixed

Committed to all branches.

sun’s picture

Title: TinyMCE & Lightbox2 compatibility » TinyMCE: Link attributes of advlink plugin are removed

Better title.

negative_sun’s picture

Status: Fixed » Closed (won't fix)

Please patch advimage settings as well - Lightbox2 also can be used on images.

sun’s picture

Status: Closed (won't fix) » Active

@negative_sun: Please read http://drupal.org/node/156119

negative_sun’s picture

Status meant to me "not yet fixed".
What about patching advimage?
Should I create separate issue for it?
BTW: How I can setup email notifications like JIRA \ mantis?

sun’s picture

Status: Active » Needs review
FileSize
976 bytes

Attached patch adds all configurable options of the advimage plugin.

negative_sun’s picture

Status: Needs review » Needs work

Please add 'rel' tag to 'advimage' patch. By default Lightbox2 uses rel, not class.

negative_sun’s picture

Status: Needs work » Active

Sorry, incorrect status again.

sun’s picture

Status: Active » Needs review

Proper status would be "patch (code needs work)". However, I am pretty sure that Lightbox adds the "rel" attribute for the surrounding link and not to the IMG tag. Prove me wrong first.

stella’s picture

Lightbox2 uses the rel attribute on links to determine if a lightbox should be triggered when the link is clicked.

Now there is some automatic image handling built-in to Lightbox2. This allows Lightbox2 to support image links provided by modules such as image, brilliant gallery, gallery2, flickr, etc, where the user has no control over the HTML generated and hence can't add a rel attribute. In such cases, Lightbox2 looks at the class name on the image (note, image, not the anchor) and with a bit of javascript modifies the DOM to add the rel attribute to the link surrounding the image. This means when the image is clicked, it will actually be opened in a lightbox.

I also extended this so users can specify a custom list of image class names, so as long as the user can enter in an anchor rel attribute or a class name for the image (still has to be a link though!), then it should work well with lightbox2.

I don't know what this means for Wysiwyg API module, but that's how Lightbox2 handles links.

Cheers,
Stella

sun’s picture

Thanks for providing some insight, Stella!

This means that adding a "rel" attribute here would be wrong. Also, AFAIK, semantically, a "rel" attribute makes only sense on an anchor, because it defines the relationship from one URL (link) to the current page.

spiffyd’s picture

Version: 6.x-0.5 » 6.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

A general rule of thumb, I would add "rel" and "style" to all link arrays array('a[...]') and image arrays array('img[...]') to make sure no rel or style attributes get filtered out.

BTW, I found that this issue applies to TinyMCE module as well.

Someone should add this by default to the adv link array in the latest dev.

sun’s picture

Version: 6.x-1.x-dev » 6.x-0.5
Status: Reviewed & tested by the community » Fixed

Committed to all branches.

DolfAndringa’s picture

Hey all, I ran into this problem as well using tinymce and drupal 6.8. Your solution worked, only the file seemed strange to me. I couldn't find any file remotely similar to the one mentioned in the patch. A little digging turned up sites/all/modules/tinymce/plugin_reg.php. This contained the extended_valid_elements arrays and I changed the one for advlink. Just for the record if anyone runs into the same problem.

sun’s picture

@smokeyd: This issue is about the Wysiwyg API module. Please read the notice on http://drupal.org/project/tinymce

Status: Fixed » Closed (fixed)

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