WordPress.org

Ready to get started?Download WordPress

Forums

How can i add an image attachment to a post without the editor? (2 posts)

  1. ScaraX
    Member
    Posted 5 years ago #

    Hi,

    I want to add an image (which is located in a subfolder of my WordPress directory) to the gallery of an existing post.

    I am using the postmaster plugin, which works fine, but the images created by this plugin are just saved in an upload directory and not as an attachment.

    Can anybody tell me the functions to add an attachment to a post?

    thanks,
    ScaraX

  2. Michael Fields
    Themer
    Posted 5 years ago #

    I want to add an image (which is located in a subfolder of my WordPress directory) to the gallery of an existing post.

    Basically, there is no simple way to do this. You will need to upload your image through the WordPress uploader for it to automatically show in the gallery. (you are speaking of the gallery shortcode, right?).

    If you are comfortable with intermediate/advanced php + WordPress, you can recode the plugin to use WordPress' core functions to save the file as an actual "attachment" WordPress style. Line # 2234 of /wp-includes/post.php has the definition of the wp_insert_attachment() function. This would be a great place to start.

    If you are not up to the coding, you could always request that the plugin author add this functionality. I scoped out his site and he seems like a nice guy.

    Best of luck,
    -Mike

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.