How to add to href of image specific CLASS and REL for jquery fancybox

jure's picture
jure
Sun, 12/23/2012 - 16:20
#1
How to add to href of image specific CLASS and REL for jquery fancybox

How to add to href of image specific CLASS  and REL for jquery fancybox?

Existing
<a href="path_to_file"><img src="thumbnail" /></a>

The goal
<a href="path_to_file" class="fancyx" rel="group1"><img src="thumbnail" /></a>

Jure

Neo's picture
Neo
Sun, 12/23/2012 - 22:44

Hi Jure,

Please describe where do you want to add this class

jure's picture
jure
Mon, 12/24/2012 - 05:46

Hello

I want to add this to news article (node/100)

The complete code is bellow

<div class="field field-name-field-image field-type-image field-label-hidden">
<div class="field-items"><div class="field-item even">
<a href=" image "> image</a> ....

I already google the solution but classic aproach to modify modules/field/theme/field.tpl.php does not give me any change
It has to be some template specification, but I do not know which file.

Neo's picture
Neo
Mon, 12/24/2012 - 10:14

You can copy field.tpl.php to md_visual/templates/ folder and change it to field--field-image.tpl.php, clear your site cache and edit your tpl files.

But I think you can use js (place this code on top of md_visual/js/script.js)

 

(function ($) {

Drupal.behaviors.md_visual = {

attach: function () {

$('.field-name-field-image a').addClass('fancyx').attr('rel','group1');

}

 

};

})(jQuery);

jure's picture
jure
Wed, 12/26/2012 - 10:57

The field--field-image.tpl.php worked excelent.

Thank you for all the help

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.