• Resolved randy111

    (@randy111)


    Hi I have created a plugin to move media files from upload folder to sub folders according to their years and months. For this I have update the wp_post table guid column and wp_postmeta table meta_value for meta_key ‘_wp_attached_file’. Everything works fine. But when an image contain srcset attribute it leads to the old location. I tried to modify meta_value for meta_key ‘_wp_attachment_metadata’. But it seemed like after modifying it all going to crash and srcset not works for the front end at all. But image displayed without a problem. How should I fix this ? a help would be much appreciate.

Viewing 1 replies (of 1 total)
  • Thread Starter randy111

    (@randy111)

    Hi actually I found the solution. what you have to do is using wp_get_attachment_metadata() and wp_update_attachment_metadata() functions. To alter the data in attachment_metadata in postmeta in wp database. It’s easier and accurate than directly involving with the ‘_wp_attachment_metadata’. In my case I took an array from get function and change the file path by altering the [‘file’] value and again save the data via update function. worked well.

Viewing 1 replies (of 1 total)
  • The topic ‘How to modify WP database so that srcset will calculated correctly’ is closed to new replies.