Posted on 14 December, 2009 By Kim Woodbridge 32 Comments

NextGEN Custom Fields Plugin: Add More Information about an Image in the NextGEN Gallery

 
Share

Vermont Field (by bengarland)

If you’ve ever wanted to add additional information about the images in your NextGEN Gallery, you can do so with the NextGen Custom Fields Plugin.

This plugin will add additional fields that you define to each image in the gallery.

The downside of this plugin, is that you have to be comfortable editing the template files. To actually display the data in your new custom field, you need to edit one or two of the templates that are included with the NextGEN Gallery plugin.

And the plugin takes a little bit of extra work to install and activate – it’s not quite as easy as most plugins. But if you want to add additional information in your image gallery, it is worth the extra work.

Note: You must already have NextGEN Gallery installed and Galleries within NextGEN.

Installation

  1. Upload the plugin to your plugins directory and activate.
  2. Put the following URL in the address bar in your web browser. http://www.example.com/wp-admin/admin.php?page=nextgen-gallery-custom-fields/ngg-custom-fields.php&mode=upgrade Make sure you change www.example.com to your own domain name. This seems to be a 2nd level of activation for the plugin.
  3. You will now have a NGG Custom Fields menu in the left navigation in the WordPress Admin.
    nggmenu
  4. Click on Setup Fields
  5. You can choose to create a custom field for individual images or for an entire gallery. I am going to continue with creating them for images.
    nggsetup
  6. Give the custom field a name, tell which galleries it should be associated with, select the type of field and then click on the Create Field button.
    nggfields
  7. Now that you have created a new custom field, you will want to add data to it. Go to Gallery > Manage Gallery and select a Gallery that you associated a custom field with.
  8. In the Gallery you will see a new blank field, which is the field that you just created. In mine I have a new field called Link and it is a URL on my site that I want to be associated with the image.
    gallery
  9. Fill in the data that you want associated with the image.

Ok, great. Now what?

You’ve created a new custom field for your Next Gen images and filled the field in with data. But now what do you do? How do you get this field to show up?

Well, you have to edit one or two of the NextGen plugin files: nextgen-gallery/view/gallery.php and nextgen-gallery/view/gallery-caption.php The first one must be edited but if you are using captions with the images, the second one must be edited as well.

  1. For images, add the following code to the template file(s) mentioned above:
    <?php echo $image->ngg_custom_fields["Your Field Name Here"]; ?>
    
  2. “Your Field Name Here” is what you named the custom field. For example, I named mine Link.
  3. For Galleries, add the following code to the template file(s) mentioned above:
    <?php echo nggcf_get_gallery_field($gallery->ID, "My Gallery Field
    Name Here"); ?>
    
  4. “My Gallery Field Name Here” is what you named the custom field for the gallery.

Now you can’t add the code to just any old spot within the template. I used mine to link each image and image description on my portfolio page to a specific WordPress page on my site.

In my next article, I will show where I placed the code and how this NextGen Custom Fields can be used to link to specific posts or pages on your own site or other locations on the Internet.

photo credit: bengarland


Related Posts:
  • Using WordPress Custom Fields to Display NextGen Gallery Slideshows Conditionally
  • How to Link NextGEN Gallery Images to an Individual Page or Post in WordPress
  • How to Create Your Own WordPress Shortcode
  • WordPress: Missed Schedule for Scheduled Posts – A Plugin Fix
  • How to Link to Your Facebook Fan Page from Your Profile Page
  • Posted In : WordPress Plugins | WordPress Tips
    If you enjoyed this post, please subscribe to my RSS Feed. You can also connect with my Facebook page or follow me on Twitter.



    32 Responses to “NextGEN Custom Fields Plugin: Add More Information about an Image in the NextGEN Gallery”


    • Hi Kim
      Great write up on the plugin. I will definitely start pointing people here to get started with it.

      Just a heads up that there is a typo in step 1 and 3 of adding the fields to templates. You got the “->” the wrong way around :-)

      Any features you would like to see added to the plugin? It’s always good to get feedback from people actually using it as intended!

      Shauno


      • Hi Shauno – Thanks! I’m going to have a part 2 on Wednesday, which actually uses a lot of info you provided in the WordPress forums.

        I double checked the code typos that you mentioned against the FAQ for the plugin and I’m not seeing the error.

        So far, it does exactly what I want it to do – it’s a great plugin but is definitely not for people who don’t want to or know how to edit template files :-)


    • Great detailed walkthrough — I like the prescriptive advice.


    • Hey Kim
      Just let me know if you have any questions, I would be happy to help. It will be great to have a place to point newbies to the plugin.

      The error is in the following places:
      <?php echo $image- It is meant to be ngg_custom_fields["Your Field Name Here"]; ?>

      The -> is the wrong way around. It is repeated <?php echo nggcf_get_gallery_field($gallery-

      Thanks again for the great write up!


    • Wow, the “greater than” / “less than” sign really messed up my last comment :)
      Feel free to delete it


    • Hey there. I’m quite new to Next Gen Gallery, but I do think this tutorial could come in handy for me too. I’m using the plugin to show my artwork, and I have it devided in seperate galleries (or well, I’m going to, since I still actually have to do it) and in my webdesign gallery I would like something along the lines of what you accomplished on your site: preview of design, preview links to page with info about the project. But as I said I’m new to the plugin and I have some issues with it. Maybe you know how to fix it.

      On this page: http://eternalised.elvenmysteries.com/artwork/pixel-art/ you can see the thumbnails for my pixel art gallery. The problem is I don’t want thumbnails here, I just want the images to show. They’re all quite small, but differ in size. I can’t just delete the thumbnail system altogether, because I would still like to use it in my other galleries (photos, drawings, etc) just not in pixel art. I tried adjusting the size of the thumbnail so they would be big enough to contain the entire images, but then my images get expanded (like, one image is about 58×169 and when I put max size of thumbnail to 200×200, the image gets really wide and hideous). If you don’t have a clue of how to fix it, you don’t have to bother. I found your tutorial really interesting and just thought you might have a better knowledge of the plugin that I have and might know what I’m doing wrong.

      Thanks in advantage.
      Morgan´s last blog ..Hello world! My ComLuv Profile


    • Kim…

      With my WordPress template… I need to figure out how to use NextGen to display the photos on the page through using Custom Field. The photos need to be placed actually in a specific place because a semi-transparent screen covers/overlaps the photo behind it.

      Believe me… I am a newbie at this. I need guidance and assistance.


    • Hi Kim

      Great tutorial! Has been a great help in getting my gallery setup with custom fields.

      I have a question however:

      I would like to display all artwork with a specific custom field in a widget. Similar to the way the categories widget can display categories.

      I.e, I have a custom field titled artist. I would like to display a list of artist names in a widget, and then have each name link to the artwork by that artist.

      Any idea how to do this??

      Here is my testing site: http://zhoom.com.au/mason/galleries/mason-test-1/

      thanks in advance!


    • Hi Ciaran – Is this a custom field that is part of a post or a custom field for the nextgen plugin?

      This article isn’t about widgets so I’m not sure if I will be able to answer the question.


    • Hi Kim

      Thanks for your response. I should have been more specific…And I don’t know why I said widget because I didn’t really mean it!

      I am using NGG Custom fields plugin and I got it working followed your instructions on this post, so thanks for that!

      I would like to know if I can create a page that displays all pictures that have a certain custom field variable attached, eg artist.

      For example, if I have a NGG custom field for artist and one of the artist names is John Smith, I would like to create a page that displays all artwork by John Smith.

      Is there a way to do this?

      I appreciate your assistance!
      Ciaran´s last blog ..Testing Site My ComLuv Profile


      • Hi Ciaran,

        Oh – I see. That would require conditional code that is searching for the content of a a particular custom field. And I have no idea – I’m sure it *can* be done but I wouldn’t know where to start – or at least I haven’t played around with figuring out something like that. I would ask on the WordPress forums for the plugin, if you haven’t already.


    • Ok, thanks anyway Kim…Great tutorial anyway :)


    • Hi, I was wondering how to display the field name before the text of the field. i.e.:

      Name of gallery: Nice Gallery
      Place: Somewhere
      Date: Sometime

      This is actually what it display:
      Nice Gallery
      Somewhere
      Sometime

      Thanks for any help!
      I hope you understand what I mean.(Sorry for my english)


    • Hi Claudio – You would need to add that text to the NextGen gallery.php file manually before the custom fields that you are displaying.


      • Thanks for your answer. I really don’t know how to do that, this is what I have actually in gallery.php:

        <div class="ngg-galleryoverview" id="anchor ?>">
        <a href="pagelink ?>">title ?>
        description) ?>

        ID, "Cliente:"); ?>
        ID, "Fecha:"); ?>
        ID, "Lugar:"); ?>

        How do I should write that text?? I would appreciate any help.

        I have like 30 galleries with different custom fields (only text fields), I would like that text to display based on the different text fields for each gallerie.

        Thanks again!


        • Sorry, this is the code:


          <div class="ngg-galleryoverview" id="anchor ?>">

          <a href="pagelink ?>">title ?>
          description) ?>
          ID, "Cliente:"); ?>
          ID, "Fecha:"); ?>
          ID, "Lugar:"); ?>


    • Hi Claudio,

      Below each image in my gallery I use a custom field that has the name of the site, which is linked.

      <a href=”<?php echo $image->ngg_custom_fields["Link"]; ?>” target=”_blank”><?php echo $image->alttext ?>

      If I wanted to have a label for it I would put Site: or whatever at the front of it.

      This is going to display in every gallery – if you want different labels in different galleries, you would need to use conditional code, which gets complicated.


    • hi,how if i want to create gallery but all images hosted on other server, is it possible with nextgen gallery ? thanks…


      • Hi John – As far as I know that can’t be done. The images need to be in the plugin’s gallery folder as part of the WordPress installation. It’s possible a different gallery plugin would handle that.


    • thanks. how do I make the custom field link work with the nextgen imageflow plugin. it doesn’t work on this. thanks.


      • Hi Paul – I haven’t worked with the image flow plugin so I don’t know.


        • Hi Kim, well it has a file called “gallery-imageflow.php” in the plugin’s “view” folder and basically an identical line as the gallery.php file where you are supposed to replace the anchor tag code. The issue is that when I replace it with the custom field code, nothing happens. I thought you might know a way to make the custom field code work in there too, since the hyperlink code looks identical to the main plugin’s code. Just trying to link out from the image flow thumbnails to a youtube video link, and then show that link in a lightbox type effect…


          • Hi Paul,

            I understand that and have been asked about this before – although the file is very similar it works differently and the instructions on this page don’t work with it. If I ever get a chance to work with it, I will write an article. Unfortunately, I don’t have the time to work on editing plugins each time someone asks me about it.


    Trackbacks/Pingbacks
    1. How to Link NextGEN Gallery Images to an Individual Page or Post in WordPress | (Anti) Social Development
    Leave a Comment
    You may use: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

    CommentLuv Enabled

    Recent Comments

      • Ari Herzog: Agreed on the updates/inbox snafu. I rarely see page updates and I know where they are! .-= Ari Herzog´s last blog .....
      • jayson: Kim, Love the themes. I am looking to update the theme on my site to something more appropriate. My site is all abou...
      • vered: "I wish more people would use this. I think it’s silly when I get updates for things occuring in Kansas and California –...
      • Dennis Edell @ Direct Sales Marketing: I was speaking generally, not specifically this month. how exactly do you work things? .-= Dennis Edell @ Direct Sales M...
      • Lucy Beer: Unfortunately I think next to no-one actually sees those "Updates". They're buried in a subsection of the inbox and I do...
      • Kim Woodbridge: Hi Marbella - Thanks! I had a great time....
      • Kim Woodbridge: Hi Julie - I'll probably try kayaking again next summer but I don't know if I will become much of a kayaker - I had a di...
      • Kim Woodbridge: Hi Vered - If you ever get the chance, you should go. It's like a different world - it's so quiet and peaceful....

    About

    Kim Woodbridge is an accomplished Information and Technical Consultant specializing in the entire implementation of a WordPress based website including installation, theme design, upgrades, unique customizations and ongoing site maintenance.

    Wordpress Services

    • Installation, upgrades and maintenance
    • Conversion of existing html and css templates
    • Theme and plugin recommendations
    • CSS customizations
    • Troubleshooting and tweaks for unique situations
    • Customization for individual blogging goals and needs
    • Training and advice