In part three of this User Submitted Image Gallery plugin tutorial series, we created the function that processes image uploads. Now it is time to build our gallery's short code, which will be used to display the complete gallery of user submitted images. This short code is rather complex and we won't fully finish it for a couple more parts yet, but by the end of this section we will have a fully paginated gallery that shows all of the images.

You must be logged in and have an active premium membership to view the rest of this content. Register or login from the sidebar.

Join now to gain access to this tutorial and more.

Join Now
  1. stansmith

    How would I add a image title, description & url link to the thumbnails?

    • Pippin

      Do you want to show the title/description of the “image” custom post type, or the title/description of the attachment file? The thumbnails are already linked to the single page for the image; do you want to link them somewhere else?

  2. David Butler

    hey Pippin, been scratching my head why the gallery when using the downloaded code was only showing 1 image. Line 84 in shortcodes.php is “‘per_page’ => 1”, I changed this value to 20 and it is looking good (I realise this could have been passed through as a parameter in the shortcode, but thought the default value should be higher).

    My next problem is that my theme is overriding the html width attributes of the image to “auto” in the gallery causing the images to fill up the width of the content box. Would it be better to setup the images dimensions dimensions in the gallery.css to avoid conflict with themes?

    Thirdly is a feature request / improvement idea. It would be nice if you could filter by image year then month (much like the post widget) and the image year is pulled from the EXIF data when uploaded… I am sure this is possible and if I figure it out – will be sure to post a copy.

    The last bit of feedback is that I will be working on allowing posted images to be approved without having to be reviewed, if you are creating a paid version of this – it would be worth considering making this an option.

    I have spent ages looking for plugins to achieve what you have created with this plugin and I am sure that I am not the only willing paying customer! I’m and nothing but a hack, but they way this is written makes it easy for me to understand!


    • David Butler

      Probably should have tried this before posting. I added the image width and height attributes in the gallery CSS wih success. BUT, I now realise why the theme was applying auto image attributes that is because it is a responsive theme… will look into a solution!

    • Pippin

      Yep, responsive themes usually remove those :)

    • Pippin

      Filtering images would be really sweet, though I doubt it will make it into a part of the series, sorry. If you’re interested in doing some custom coding on it, I can provide a little guidance.

    • Pippin

      You will want to look at the add/remove_query_arg() function. To remove pagination, use remove_query_arg( ‘image-page’)

  3. David Butler

    Thanks Pippin, got the date filtering added in and it is working well (I am sure it could do with a tidy up from my hacking).

    Here is the modified gallery code:

    The only thing I am struggling with is filtering after pagination (I don’t think my modifications have introduced this issues). For example, if I am on page 5 of the images and apply a category filter the page parameter stays in the URL and the page displays “No images found.”

    When applying a filter (changing the query) the page should default back to page 1, but I am struggling to find a solution to this. Any ideas?

    Now onto the EXIF data import…

Your email address will not be published. Required fields are marked *

Error: Please enter a valid email address

Error: Invalid email