I am trying to hook wp_get_attachment_url()
with my custom implementation. I am trying to get my post images and any other static data from the Amazon S3 and I was wondering if I can configure the URL with my Amazon bucket URL.
This is what I was trying to do
add_filter('wp_get_attachment_url', 'custom_get_attachment_url', 1, 1);
function clrs_get_attachment_url($post_id = 0) {
// change URL for Amazon bucket
}
but this is not working as expected as I am getting $post_id
as 0
. How to do it in a proper way?
Hook wp_get_attachment_link for this purpose. Here is an example of how to do it –