Upload images to post/page gallery dynamically

Hello all!

I was wondering if anyone can point me in the right direction. Does Wordpress have any built in functions, hooks, filters, etc., to dynamically attach images to a post or page, but as a gallery?

I have all of the separate components I need to start building a really functional front-end image uploader that allows a person to choose images from various places (Facebook, Instagram, etc.).

I would like to make this as light weight as possible, which gave me the idea of using the built in Wordpress gallery functionality. I want to code my uploader to attach the files to a specific page/post and automatically place them in as a gallery attachment.

Is this possible? I am so close!

  • mediastead
    • The Crimson Coder

    @Jack Kitterhing,

    No, you're not misunderstanding. I have some code that will help me build a front-end uploader that can choose images from Facebook, and I'd like to hook into the built in Wordpress gallery, so the images get uploaded to the media library, and attached to a specific post.

    I am thinking that this can be a great little widget, where someone can place the widget anywhere they want (maybe even create a short code to attach it inline with content, too) ... the widget can have a text field to place a post/page ID ...

    There are a bunch of great ways to make it work.

    Where I am stuck is which Wordpress function (if there is one) can hook into the built in Wordpress gallery shortcode?

    I am looking into wp_insert_attachment, and media handle upload, but they don't seem to have an attribute that specifically tells Wordpress to attach the image into the gallery.

    I know this doesn't fall under the realm of WPMUDEV Support, but any ideas would be appreciated.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.