WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] Easy Fancybox on custom home.php (is_home()) (8 posts)

  1. achensee
    Member
    Posted 3 years ago #

    I am using a gallery on a custom home.php. To get easy fancybox work on on a custom Homepage, i found out that it is necessary to replace easy-fancybox.php in line
    972 if ( is_single() || is_page() ) {
    with
    972 if ( is_single() || is_page() || is_home() ) {

    Maybe you could include this little change for future updates?

    http://wordpress.org/extend/plugins/easy-fancybox/

  2. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    In what way is Easy fancyBox not working on your home page? Whether WP regards your home page as a single PAGE/POST or as an ARCHIVE only should make a difference in which gallery method FancyBox uses. Not in it working or not working...

    But I can image one case where it would NOT work: when your custom template file does not use class post for each entry, the jQuery script will skip any images.

    There are two possibilities to get around this:
    1. Give the wrapping DIVs that include each entry in your home.php loop the (extra) class name post.
    2. Set WP to use a single PAGE as home page.

    You see, adding is_home() to the if statement in easy-fancybox.php would impact all users that have a standard ARCHIVE home page by presenting images from different post as one gallery...

  3. achensee
    Member
    Posted 3 years ago #

    Hi Ravan, thanks for suggestions, but there are very good reasons for a custom home.php instead of a single page when using wordpress as cms for rich interactive websites - have a look at http://codex.wordpress.org/Template_Hierarchy#Visual_Overview

    I don't think that adding is_home has negative impact of other users, they might have the same problem.

    without my modification on home.php your script writes out the following in to the <head>-section:

    ...
    /* IMG */
    var fb_IMG_selector = 'a[href$=".jpg"],a[href$=".JPG"],a[href$=".gif"],a[href$=".GIF"],a[href$=".png"],a[href$=".PNG"]';
    var fb_IMG_posts = jQuery('div.post');
    fb_IMG_posts.each(function() { jQuery(this).find(fb_IMG_selector).addClass('fancybox').attr('rel', 'gallery-' + fb_IMG_posts.index(this)); });
    $('a.fancybox').fancybox( $.extend(fb_opts, { }) );
    });
    ...

    which causes images outside the_post not to be tagged with fancybox.

    with my modification on home.php your script writes out the following in to the <head>-section:

    ...
    /* IMG */
    var fb_IMG_selector = 'a[href$=".jpg"],a[href$=".JPG"],a[href$=".gif"],a[href$=".GIF"],a[href$=".png"],a[href$=".PNG"]';
    $(fb_IMG_selector).addClass('fancybox').attr('rel', 'gallery');
    $('a.fancybox').fancybox( $.extend(fb_opts, { }) );
    });
    ...

    which causes every image on a page to be tagged with fancybox - that is exactly what i need, because of a ng-gallery in the widget section.
    you can have a look here

  4. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Hi achensee, notice the jQuery('div.post') in that first output. It means the script is looking for divs with class post and then attaches FancyBox to any images inside those divs. With in each div a different gallery tag. This should result in images from ONE post that are in ONE div (with class post) being grouped in ONE gallery and images from ANOTHER post in ANOTHER gallery.

    Right now, with the second output on your home page, all images are grouped in the SAME gallery. Open for instance the first image under Skivergnügen and then hover with your mouse over the right side of the overlay image. You will be able to click there and move to the next image which belongs to the Langlaufen section...

    If that is alright with you, there is no problem with using is_home() :) but most users do not want images from different posts to 'mix' in this way...

    I will consider some solution like making this optional in the next release but I cannot guarantee anything.

    In any case (if you do not want to keep editing the plugin source) these alternative suggestion will work:
    a. Make the wrapping div of each entry in the template file use the class post or...
    b. Give each image link that you want opened in an overlay the class fancybox.

  5. achensee
    Member
    Posted 3 years ago #

    Hi Ravan, thanks for your reply and suggestions. for my purpose it is okay that the gallery group is mixed up - from the users/guests point of view there is more to see without more to click. It would be great to have that option in future release of the plugin. because more and more wordpress becomes an ingenious tool to build fully functional websites where not only one post_loop is used for displaying content. if i can help you in further developing the plugin, just let me know. donation is on the way...

  6. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Thank you achensee, your tip is highly appreciated!

    And to show that appreciation, your request will get a front row seat for inclusion in the next release :)

  7. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    achensee, in the new version 1.3.4.6 there is an option to switch off this behaviour on the Settings > Media page.

    Look for the select-box Auto-gallery in the section Images and set it to 'None' after upgdrading.

  8. achensee
    Member
    Posted 3 years ago #

    Great enhancement; i am sure many devs will use it - thank you very much.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic