WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Custom Fields
Displaying content from custom fields in Shutterbox's image ove (3 posts)

  1. Dom
    Member
    Posted 2 years ago #

    Using:
    WP 3.3.1
    NextGEN Gallery 1.9.2
    NextGEN Custom Fields 1.2.1

    Hi all,

    I've sort of run into a stopping place with what should be an easy problem to solve. But maybe someone can lend some insight, or suggest attacking the problem in a different way.

    Essentially, I am using the stock Shutter Reloaded overlay effect that comes with NextGEN Gallery. (I'm happy to try a different overlay solution if you can suggest).

    I am also using NextGEN Custom Fields for a new field called "Image Source". Not only do I want to see the image description (title tag) in the overlay, but also the text entered for "Image Source".

    Here's the tricky bit:
    The shutterbox overlay is created with JavaScript: I can't pull the "Image Source" string from the database in any sort of easy way.

    My not-so-brilliant solve:
    Using the PHP provided by the fantastic Shauno, I'm putting the string on the page, under each thumbnail image, in a paragraph with the style {display: none;}. Then I will use JavaScript to find the text spitted onto the DOM by the PHP, and render it in the image overlay (or lightbox, whatever you want to call it).

    My PHP from the gallery page (gallery.php):

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    My JavaScript from shutter-reloaded.js:

    var imgSource = document.getElementById('imgSource').innerHTML;
    
    NavBar = '<div id="shTitle"> <div id="shPrev">' + prevlink + '</div><div id="shNext">' + nextlink + '</div><div id="shName"><p><strong>Description:</strong> ' + shutterLinks[ln].title + '</div>' + imgSource + ' ' + imgNum + '</div>';

    Okay, now this is the weird part: when shutter-reloaded.js grabs the content p#imgSource, it totally writes: "Source: " under the image's description. But nothing from the content that the PHP is putting on the page.

    Thoughts? Am I nuts? Do I rethink the entire design of having the custom fields content appear in the lightbox overlay?

    Thanks all,
    Dom

    http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/

  2. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    Getting the custom fields to display in the various overlays has been a frequently asked question by users.
    The last time I really made an effort to look into it was quite some time ago. The conclusions I came to thanm were that the js didn't provide enough events to be able to inject into the markup without hacking all sorts of files.

    That being said, the solution you are trying with hidden content injected into the nav bar should work. But if your custom field is simple text, you can just output it into the title attribute of the image anchor, and shutter will show it for you :)

    So, something like title="<?php echo $image->description ?> | Source: <?php echo $image->ngg_custom_fields["Image Source"]; ?>"

    Hope that helps
    [ Signature moderated. ]

  3. Dom
    Member
    Posted 2 years ago #

    Yeah, I wish that injecting into title would work, but on my pages, I've got 3 galleries with many images in each one. So it goes.

    I'm passing the problem off to a coworker to see if he can work some magic. :)

    Thanks for the reply Shauno.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic