February 2, 2016

Fix the CDN missing images for your SSL site

If you ever find such a problem that not all of you files get uploaded in CDN. You know you can migrate images but it takes some time there is not a full surety that all images will be uploaded to CDN.

So If you put a CDN link like

db79e2070b0c95965a69-f4ee703189c46af6fe45f026a70dab33.ssl.cf2.rackcdn.com

will not found missing images.

Using a CURL to know your missing images is the worst Idea Ever.  CURL is a server end process and You can check this on client END too. The Idea is to check the error images and replace it with your server directory, which is your base site director not a CDN.

So missing images will be coming from your serer and CDN images will be coming from CDN

Follow the below code and Have fun

function fix_cdn_url(){
$(“img”).error(function () {
var source = $(this).attr(‘src’).replace(‘db79e2070b0c95965a69-f4ee703189c46af6fe45f026a70dab33.ssl.cf2.rackcdn.com’,’www.sitename.com’);
$(this).unbind(“error”).attr(“src”, source);
}); }

fix_cdn_url();

 

You may also like...

Leave a Reply