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.
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.