Support » Developing with WordPress » Custom upload media structure

  • Hi,

    I am in the process of writing a custom plugin and I am looking for a way to restructure and customize the directories WordPress uses to upload files.
    Ideally I want all the original/high res image to go into one directory, but all derivative/lower resolution images to go into dated folders.

    The reason to separate the source files from the cached ones, is to have a clean folder with just the originals to make future migration easier. It would also make it easy to swap and update an already imported image, by manually overwriting some of the images on server and then forcing WordPress to regenerate the derivatives.

    In which parts of WordPress would I need to add code to make such a change?

    thanks

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Have a look at source code for wp_save_image_file(). What to do depends on whether the installation can instantiate an object of WP_Image_Editor class or not. You would use the filters available to short circuit the default image save process in favor of your own process.

    Strictly speaking, the only place you will “add code” is within your own plugin files. Such code can alter what WP code does by hooking filters and actions.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom upload media structure’ is closed to new replies.