Adding images to a gallery from the Media Library

What’s the difference between WordPress’s Media Library and the images I uploaded to posts and pages? Why can’t I add images from the Media Library to galleries in my posts and pages? WP expert Otto explains it like this:

The “gallery” feature is tied to a specific Post. All the images uploaded through the post editor become that specific Post’s gallery. If you upload them through the media section, then they cannot be in a gallery.

Don’t think of a gallery as some separate entity, because it’s not. A “gallery” is simply a bunch of images that are attached to some specific Post. It’s not some thing that you can move images in and out of, it’s not like a photo album or something.

WordPress really has no support for image groupings, albums, or anything similar. The gallery feature merely shows all images that are attached to a specific Post.

Wouldn’t it make more sense to upload all of my images to the Media Library then associate them with whatever post or page as needed, rather than re-upload the same images again and again to each post/page? I’ve had a few clients with this problem exactly, and it’s hard to explain why this doesn’t work. But there is a workaround for adding images to galleries using the gallery shortcode. Once you have uploaded your image to the Media Library, view the image and get it’s id from the URL:

Then go to the HTML view of your post/page editor. Add this, replacing the numbers with the ids of you chosen images:

The gallery shortcode can manipulate any aspect of the gallery, including it’s size, number of columns, position on the page, and the order of the images. Take a look at these other features in the Codex.

Big thanks to Amelie who posted this tip in the comments here at the WPFolio Wiki!

This entry was posted in News. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

6 Comments

  1. Posted February 12, 2012 at 9:55 am | Permalink

    what about the Nextgen plugin?

  2. Posted March 5, 2012 at 3:12 pm | Permalink

    Hi there!
    I can’t seem to find where the attachment id is for images–they seem to only have the original filename.
    Any suggestions?
    Thank you, Joanna

    • Posted March 20, 2012 at 9:51 am | Permalink

      Go to the image’s page. If you’re in the gallery, you’ll see a box for “Link image to” (or something similar) and choose Attachment. The URL will look like the one I marked in the photo above.

  3. Posted March 21, 2012 at 10:59 am | Permalink

    There’s also a plugin for unattaching files from a post so you can attach them to another in Media:
    link to outlandishideas.co.uk

  4. Posted June 18, 2012 at 7:35 pm | Permalink

    And how does one center image columns in a gallery? I have tried the toolbox in the visual editor and code [align=”center”], both to no avail. Any suggestions?

Post a Comment

Woah woah woah! Thinking about leaving a comment? If it starts anything like "How do you…" or "I can't figure out..." then head over to the WPFolio Support Article and read through it. Posting on WordPress Support is usually a better idea.

If you're going to post a comment, consider making a donation at the same time.

Your email is never published nor shared.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

Are you signed up for     WPFolio email updates? »