0
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array

Could you please specify which database table is referred for to retrieve the image source url?

0

Images (and all other attachments) are associated with a post in the posts table. The attachment source URL is saved in the guid column.

enter image description here

That’s not a good choice, because sooner or later GUIDs won’t follow the URL scheme anymore, so don’t query that field directly.

  • Thanks for the quick response. If I upload all the media files to amazon s3 and modify the guid path, will it then point to new amazon path like below? UPDATE wp_posts SET guid = replace(guid, 'www.mydomain.com/wp-content/uploads/2013', 'test.s3.amazonaws.com/wp-content/uploads/2013'); – user40991 Oct 28 '13 at 10:38
  • In case you are moving all your images/upload folder to amazon, you need to make a small change in the wp-config.php file to make it work. Follow the link for details wordpress.stackexchange.com/questions/120326/… – Maruti Mohanty Oct 28 '13 at 11:00
  • @user40991 How the URL is stored for external services depends on the plugin you are using for that. – fuxia Oct 28 '13 at 11:01

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.