1

I would like to move (or copy) an attachment from the the "standard" uploads directory to another directory and at the same time make sure all the attachment metadata is updated to reflect the change in directory and all image sizes are created..

The 2 functions I would imagine would be:

move_attachment_file($attachment_id, $old_directory, $new_directory);

copy_attachment_file($attachment_id, $old_directory, $new_directory);

Are there any such functions? If not could someone point me in the right direction and let me know which functions I have to use to accomplish that. Then I can try and code it myself, but I am a bit lost to start with.

0

The problem is that even if there was such a function (I am not aware of one) all older links to those files would need to be updated as well. As links, src of images,... in the content of posts aren't linked to the attachments in the DB but just HTML in the posts content this is pretty complicated to achieve.

  • ok! That is a good point. Though I think in my case it might be still ok. All I do is get images by their ID in the template i.e with the gallery shortcode. – Sascha Feb 20 '14 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.