Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3228302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:40:34+00:00 2026-05-17T16:40:34+00:00

Im using [drupal_add_js_()][1] function to add a fancybox effect to some image in my

  • 0

Im using [drupal_add_js_()][1] function to add a fancybox effect to some image in my nodes (im not using the Fancybox module becose doesnt fit my needs).

In short, i need to add the titleFormat function to format the image title; In my javascript file, it looks like:

$("a[rel=myfancy_group]").fancybox({
    'transitionIn': 'elastic',
    'transitionOut': 'elastic',
    'titlePosition': 'over',
    'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
        return '<span><b>' + title + '</b> | Image ' + (currentIndex + 1) + ' of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    }
});

And this is how my drupal_add_js function looks:

drupal_add_js(
    array(
        'mycustom_fancybox' => array(
            'selector' => 'div.field-field-immagini-minigallery a',
            'group' => TRUE,
            'options' => array(
                'transitionIn' => 'elastic',
                'transitionOut' => 'elastic',
                'titlePosition' => 'inside',
                'titleShow' => TRUE,
                'width' => 500,
                'cyclic' => TRUE,
                'titleFormat' => ???
            )
        )
    ),
    'setting',
    'footer',
    FALSE,
    TRUE,
    TRUE
);

EDIT i’ve tryed with:

//add fancybox settings
drupal_add_js(
    array(
        'mycustom_fancybox' => array(
            'selector' => 'div.field-field-immagini-minigallery a',
            'group' => TRUE,
            'options' => array(
                'transitionIn' => 'elastic',
                'transitionOut' => 'elastic',
                'titlePosition' => 'inside',
                'titleShow' => TRUE,
                'width' => 500,
                'cyclic' => TRUE,
                'titleFormat' => "function my_title_format(title, currentArray, currentIndex, currentOpts) { return '<span><b><i>' + title + '</i></b> | Immagine ' + (currentIndex + 1) + ' di ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>'; }"
            )
        )
    ),
    'setting',
    'footer',
    FALSE,
    TRUE,
    TRUE
);

but (as i supposed) Drupal render it like:

"function (title, currentArray, currentIndex, currentOpts) { return \'\x3cspan\x3e\x3cb\x3e\x3ci\x3e\' + title + \'\x3c/i\x3e\x3c/b\x3e | Immagine \' + (currentIndex + 1) + \' di \' + currentArray.length + (title.length ? \' \x26nbsp; \' + title : \'\') + \'\x3c/span\x3e\'; }"

…and it doesnt work.

I tryed

drupal_add_js(
    array(
        'mycustom_fancybox' => array(
            'selector' => 'div.field-field-immagini-minigallery a',
            'group' => TRUE,
            'options' => array(
                'transitionIn' => 'elastic',
                'transitionOut' => 'elastic',
                'titlePosition' => 'inside',
                'titleShow' => TRUE,
                'width' => 500,
                'cyclic' => TRUE,
                'titleFormat' => 'my_title_format'
            )
        )
    ),
    'setting',
    'footer',
    FALSE,
    TRUE,
    TRUE
);
//and, in my js file, added:
function my_title_format(title, currentArray, currentIndex, currentOpts) {
    return '<span><b><i>' + title + '</i></b> | Immagine ' + (currentIndex + 1) + ' di ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
}

But again doestn work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:40:35+00:00Added an answer on May 17, 2026 at 4:40 pm

    Take a look for js Drupal.theme mechanizm.
    Example I took from module/block/block.js

        // A custom message for the blocks page specifically.
      Drupal.theme.tableDragChangedWarning = function () {
        return '<div class="warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t("The changes to these blocks will not be saved until the <em>Save blocks</em> button is clicked.") + '</div>';
      };
    

    It can be usefull. But it realy looks you need just separated js file that will get Drupal.settings you need and insert them to code applied fancy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My drupal site (internal) will not display the TinyMCE editor when using Google Chrome
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Is anyone out there using Drupal for large scale, business critical enterprise applications? Does
When you create a new content type in Drupal using the Content Creation Kit,
I have the occasion to produce Drupal web sites using development, staging, and production
I'm creating a form using the Content Construction Kit (CCK) in Drupal5. I've added
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.