I recently installed ta plugin that now uploads my images from the media library to s3.
I have also FTP's the entire uploads folder to s3 which encompasses about 4000 images.
I have used throughout my site the wordpress gallery shortcode however somewhere and somehow it outputs the siteurl.
How do I change this so that I can override the url to be the one from my S3 bucket?
I will admit I have no idea what I am doing here or where to start and I really will appreciate your help :)
Basic Usage To get started with the [gallery] shortcode go to Posts section and add a New Post which we will call "Gallery Post". In the editor area place the shortcode [gallery] (in either the Visual/HTML View). After that press Publish/Update.
When you click any area of the image gallery, icon buttons appear top of the area. At any time, you can edit the images or settings of your gallery by clicking on the Edit button. You can remove the image gallery at any time by clicking on the Remove button.
You can filter images src attribute output and replace old url with new url as follow. copy below code to your theme functions.php
and replace www.oldurl.com
and www.newurl.com
with your own urls.
add_filter('wp_get_attachment_image_src', function ($image) {
if(is_array($image)){
$image[0] = str_replace('www.oldurl.com', 'www.newurl.com', $image[0]);
}
return $image;
}, 999);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With