• Resolved markisu72

    (@markisu72)


    Hi,

    we recently implemented a CDN on our site and I found out, that when selecting different variations, the underlying JS loads the file from the original server URL (which usually is the right approach).

    But with a CDN in place (which simply uses a different server name with the same resource path) this completely bypasses the CDN (unless you use a proxy CDN which we decided against).

    Is there a way to configure / hook into the code to replace the standard server name with a different one, so that the original URL

    https://www.mynormalserver.com/path/to/image

    can be modified to

    https://this.is.my.cdn.com/path/to/image

    ?

    This would be very important for us (and I suppose for thousands of other users, too).

    Thanks

    Markus

    • This topic was modified 1 year, 3 months ago by markisu72.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter markisu72

    (@markisu72)

    Hi,

    ich found a solution by applying a filter:

    function alterImageSRC($image, $attachment_id, $size, $icon) {
    	$image[0]=str_replace(get_site_url(),"CDNURL",$image[0]);
    	return $image;
    }
    
    add_filter('wp_get_attachment_image_src', 'alterImageSRC', 10, 4);

    Works for me.

    Markus

    Thread Starter markisu72

    (@markisu72)

    Hmm. Seems only to cover part of the cases…

    Plugin Support villasupport

    (@villasupport)

    Hi,

    The issue with the CDN doesn’t appear to be related to our plugin, actually.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Provide different URL for images’ is closed to new replies.