WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] display direct link in title (37 posts)

  1. cellobrutos
    Member
    Posted 3 years ago #

    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?

    Thanks,
    F.

  2. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    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 http://fancybox.net/blog

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

  3. cellobrutos
    Member
    Posted 3 years ago #

    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: http://home.francoissechet.com/musicaglotz/musiciens/altinoglu-alain/ (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?

  4. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  5. cellobrutos
    Member
    Posted 3 years ago #

    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.

  6. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

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

  7. cellobrutos
    Member
    Posted 3 years ago #

    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.

  8. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    try

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

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

  10. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    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>\';}

  11. cellobrutos
    Member
    Posted 3 years ago #

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

  12. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    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!

  13. cellobrutos
    Member
    Posted 3 years ago #

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

  14. mctarq
    Member
    Posted 3 years ago #

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

  15. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    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?

  16. mctarq
    Member
    Posted 3 years ago #

    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 http://www.hernancruzsomavia.cl.

  17. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    mctarq,

    This thread is about the plugin Easy FancyBox. You are using another plugin. Please go to http://wordpress.org/tags/fancy-box?forum_id=10 for support on Fancy Box, or switch to Easy FancyBox :)

  18. mctarq
    Member
    Posted 3 years ago #

    Thank you very much RavanH! I've just installed EasyFancyBox and I configured it (the animation and the text position)....do you know how to insert the tittles in each picture?? Thanks a lot!!!

  19. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Give the LINK a title ... or ... Check the option "Title from Alt" in the Easy FancyBox settings the IMG an alt attribute.

    To give the link a title in the Visual content editor, click the thumbnail image and then click the link icon in the Rich Text Editor toolbar. Fill in the title of the image in the title field.

    Tip: try class="fancybox iframe" on the link to your video...

  20. mctarq
    Member
    Posted 3 years ago #

    RavanH!!! you've saved me!!!! it's OK! now I have titles! thanks a lot por your help!!!

  21. mctarq
    Member
    Posted 3 years ago #

    Hi,
    how can I insert arrows in thee images to pass to the next image? I've checked in the Setting Media toolbar the option "Show the gallery navigation arrows" but nothing happens....
    Thanks!!!

  22. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    In Settings > Media, there is a field called Section(s) which determines where the script should look for images to automatically group in one gallery. Adapt this to fit your theme by changing article, div.hentry to div.entry. Remember that if you change yout theme one day, you might need to adapt this setting again to work with the new theme.

  23. mctarq
    Member
    Posted 3 years ago #

    Hi RavanH,
    how can I introduce "line text jumps". This is because I need to put a title in two languages and it's the best way toy separate both.
    Thanks a lot!

  24. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    mctrarq, i have no idea what you mean...

  25. Tara Rotten
    Member
    Posted 3 years ago #

    Hello i was reading your above comments about linking the title. i have pasted

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

    into easybox setting php however the title isn't linking. any ideas?

    also i was wondering if it is possible to display the post title instead of the alt and have it link to the post page??

  26. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Tara,

    I have stopped supporting customizations. It just takes way too much of my time. Sorry.

    Should note though: you can hire me to do custom work like this. :)

  27. Tara Rotten
    Member
    Posted 3 years ago #

    Thanksss. wil have to sort out a little money for you. in the mean time have you ever posted anything on adding anchor tags to the fancybox links?

  28. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    What do you mean by "adding anchor tags to the fancybox links?"

  29. Tara Rotten
    Member
    Posted 3 years ago #

    So you have
    so fancybox can do custom open on load :)

  30. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    I still do not follow... An anchor tag is generally known as a 'link' (that's why the html tag starts with <a for anchor) so what does adding a link to a link mean?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic