Support » Plugin: Easy FancyBox » [Plugin: Easy FancyBox] display direct link in title

  • Resolved cellobrutos


    Hi there,

    Right now, when displaying images, easy-fancybox grabs the title of the actual image, and echos it.
    What I would like to do would be to be able to display the title of the actual image and add a link to the actual file. For example:

    image title | <a href="image_link.jpg">download in HD</a>

    Is such a thing possible, and if yes, how?


Viewing 15 replies - 1 through 15 (of 36 total)
  • Plugin Author RavanH


    Custom titles like that are not possible with my plugin. You can do it with FancyBox in stand-alone mode, though it’s not the most easy thing to accomplish. You can find an example on

    But you might try the following approach:
    – Keep Easy FancyBox and make sure the option “Use Title from Alt” is checked.
    – Give your images title and alt attributes as the following example:

    <a href="http://.../.../thumbnail.jpg"><img title="Image Title" src="http://.../.../medium_size_image.jpg" alt='Image Title | <a href="http://.../.../HD_size_image.jpg">Download in HD</a>' width="..." height="..." /></a>

    Notice the use of single (‘) instead of double (“) quotes wrapping that alt text because it has double quotes inside it!

    I have not tested it but it might be worth a try 🙂

    Thanks for the quick answer… I actually had the regular fancybox before exactly for that reason, but changed it to the wordpress gallery thingy for ease of use (I’m not the end user – I myself wouldn’t mind).

    Actually what does work is when uploading the file, you can just add an href with the link to the image (a few lines below) around the text you want to see in the title. Works like a charm, first picture in the “photos” section here: (local link, might be down when I turn off my NAS). BUT it is quite complicated to use, and not what my client is asking for… Way too complicated for them. But being that I use the video option of the same plugin, I would like to keep the general feel of it.

    What I would have guessed is that there is a way to get the title and the link of the image as a variable and modify by myself your plugin in such a way that instead of echo $title, it would show something like echo $title .' | <a href="' . echo $link . '">some text</a>'

    How does this sound?

    Plugin Author RavanH


    Hmmm… My plugin does not do any echo $title stuff. That’s all handled by the FancyBox script. So if you want to modify the title, you need to incorporate the official FancyBox method, as you have used before apparently, into the plugin. This can be done, but it won’t be easy. Nor will it stick on the next upgrade…

    But to get you started: take a look at the file easy-fancybox-settings.php which is basically one big array of settings. First the Global settings, then IMG settings then the others like Youtube, PDF … Do a search for titleFormat and you will find an inactive piece (starting with /* and ending with */) in the Global section. You can activate it by removing the /* and */ and edit the part after function(title, currentArray... so the title will look like you want. Note: you need to place a backslash before each single quote you use in your custom code!

    If you leave it in the Global section, this title format will also apply to all other formats so you might want to move down to the IMG section.

    well, removing the /* */ kind of breaks my whole site, so… no.

    Alternatively: do you know what function in wordpress handles the title and link of the gallery images? I could try to fiddle in there and if I can’t get the “title” section to display what I want to see.

    Plugin Author RavanH


    that is why that part is edited out. not tested and not implemented as a setting (yet) but it should be possible that way.

    you will need to find the cause of that breakage. it sounds like a missing comma or an unescaped single quote somewhere…

    It was indeed a coma I missed after “Mimic Lightbox2 style”… thanks for the pointer.

    So I started a fresh new option there, and here is what I’ve got as of now:
    function(title, currentArray, currentIndex, currentOpts) { return \'<div style="some styling">\' + title + \' | <a href="link">' . __('Download HD file','easy-fancybox') . '</a></div>\';}

    This is quite exactly what I want – but my problem is, where do I get the image link? I just need the link to the image that fancybox is currently displaying, not to a bigger version of it.

    Plugin Author RavanH



    function(title, currentArray, currentIndex, currentOpts) { return \'<div style="some styling">\' + title + \' | <a href="\' . currentArray[currentIndex].href . \'">Download HD file</a></div>\';}

    Nope, this way I’m entirely loosing the fancybox.

    Plugin Author RavanH


    sorry, there is an error in that javascript (using . instead of + , confused with PHP there) function(title, currentArray, currentIndex, currentOpts) { return \'<div style="some styling">\' + title + \' | <a href="\' + currentArray[currentIndex].href + \'">Download HD file</a></div>\';}

    This works like a charm! Thank you! You could really allow some default settings like that in the next version…

    Plugin Author RavanH


    That’s why that rudimentary code is already in there… But I cannot promise anything for the coming release.

    Please keep an eye on the upgrade notice (or the changelog) before upgrading or you might loose your current customisation!

    Yes of course! I’ve already got some incremental backups of this project so I can always reverse in case something bad happens.

    could someone help me with fancybox title?? I need to insert a “title inside” in a fancy image and I have read a lot of forums but I didn’t found the answer…pleeeease!!!

    Plugin Author RavanH


    mctarq, are you using a wordpress plugin to get FancyBox running on your site or are you using the bare FancyBox script in your theme template files?

    I have activated fancybox pluggin on my web and when I click on the pictures, they open like a fancybox but without a title and I don’t know the part of the code to insert it and where. The page is

Viewing 15 replies - 1 through 15 (of 36 total)
  • The topic ‘[Plugin: Easy FancyBox] display direct link in title’ is closed to new replies.