WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Lightbox Gallery] Display scripts only when gallery is used (4 posts)

  1. CDSanchez
    Member
    Posted 5 years ago #

    Is there any way to only display the jquery and lightbox scripts only on a single post, AND when that post has a gallery (not images, but only if the [gallery] shortcode was used)?

    This is the only feature that uses jQuery, so I don't want to make my users download something that I only use every once in a while.

    Also, what's new in the new update?

  2. Hiroaki Miyashita
    Member
    Posted 5 years ago #

    This plugin does not support for displaying lightbox scripts on the specific posts at present. I will consider about this in the next release.

    Check my plugin page for the release history. At this time, it is a minor bug fix. Thanks.

    http://wordpressgogo.com/development/lightbox-gallery.html#english

  3. CDSanchez
    Member
    Posted 5 years ago #

    I tried editing your plugin to see if I could do it myself, but I couldn't figure it out. When you do decide to implement this, take this in mind: only display the scripts when a gallery is used, not when an image is attached to the post.

    I tried:

    if (do_shortcode('[gallery]')) {
    //display scripts
    }

    and

    if (gallery_shortcode($post->ID)) {
    //display scripts
    }

    But those two will display the scripts if the post has an image attached, regardless of whether an actual gallery was inserted. Someone suggested iterating through an array created by the shortcode_parse_atts() function and searching for the [gallery] short code, but I haven't tried it out:

    $array = shortcode_parse_atts($post->post_content);

    Other than that, it's a pretty good plugin and does what it says. The only thing I think would be nice, in addition to the scripts feature I mentioned above, is an option page to change the default size on the images so we don't have to change the size in the gallery shortcode every time.

  4. Hiroaki Miyashita
    Member
    Posted 5 years ago #

    I am sorry for my late reply. I released the new version which outputed lightbox scripts only in the related pages. Let me know if you find something wrong. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic