WordPress.org

Ready to get started?Download WordPress

Forums

Image upload save locations: post vs. page (1 post)

  1. gendem
    Member
    Posted 1 year ago #

    This is difficult to describe, so bear with me.

    The gist of it is that if I upload an image using the built-in media uploader, it is saved to different locations depending on whether the image is uploaded as part of a post or a page.

    Ex. 1
    Create a new PAGE, and set the date of the page to January 2010. Upload an image.
    Result: the image is saved to [current year]/[current month]

    Ex. 2
    Create a new POST, and set the date of the post to January 2010. Upload an image.
    Result: the image is saved to 2012/01/

    They both use the same upload mechanism, so the difference in upload locations must come down to either (a) how the uploader is called, or (b) a post type check is done, and the logic saves it one way for posts, and one way for everything else.

    The root of the question is that I have a plugin that has a custom post type (CPT). I want my CPT to operate like a post (uploaded images get put in the folder based on the date of the custom post type) not like a page (uploaded images get put in the folder based on the date the images are uploaded, regardless of the date of the page itself).

    Can anyone point me in the right direction?

Topic Closed

This topic has been closed to new replies.

About this Topic