Support » Plugin: WordPress prettyPhoto » Sample of how to use your WordPress prettyPhoto

  • Resolved Amber

    (@syrehn)


    How can I get my images/galleries on page/posts/custom post types to trigger your prettyPhoto plugin.

    Do you have sample of code to add to functions.php in a theme file for this since it requires adding rel=”prettyPhoto” to images and there is no way to do that by default in WordPress currently.

    http://wordpress.org/extend/plugins/prettyphoto/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Babar

    (@ibabar)

    If you go for functions.php method all your images and links will open in prettyphoto by default.
    I think it’s not a good idea, that’s why I haven’t implemented that.

    You can simply add the rel=”prettyPhoto” tag with the image links you want to open with rettyphoto.

    I’m unable to add rel=”prettyphoto” to images that are embeded using the default WP Gallery feature. Galleries are added via a shortcode. How can I get your plugin to work with the default WP Galleries?

    Plugin Author Babar

    (@ibabar)

    No way for now.
    You will have to write markup manually.
    Or if you are proficient with php you may write a filter function to override default WordPress gallery shortcode.

    It actually seems to be not working at all for any image.

    If you see the following url you can see that even though your plugin is active and the rel=prettyPhoto is applied it’s not working: Test

    Plugin Author Babar

    (@ibabar)

    Your theme doesn’t have any jQuery included.
    Please include jQuery => 1.8.3 on your theme header to use prettyPhoto.

    o_O Talk about a blonde moment; this is a sign that working at 3am is bad. I didn’t even realize that jQuery was not being included in Twenty Twelve I just assumed it was.

    Derp! Enqueued jQuery in the Twenty Twelve functions and all is good now. 🙂

    As a side note, after a bit of googling if anyone else wants to use your plugin with galleries they can use the following in their functions.php (courtesy of Remi Corson):

    /* ------------------------------------------------------------------*/
    /* ADD PRETTYPHOTO REL ATTRIBUTE FOR LIGHTBOX */
    /* ------------------------------------------------------------------*/
    
    add_filter('wp_get_attachment_link', 'rc_add_rel_attribute');
    function rc_add_rel_attribute($link) {
    global $post;
    return str_replace('<a href', '<a rel="prettyPhoto[pp_gal]" href', $link);
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sample of how to use your WordPress prettyPhoto’ is closed to new replies.