CDN – List URLs
-
Hi,
I am having a problem with CDN. Our html likes below
<div data-urls="url-1,url-2,url-3"></div>We use CDN (Generic Mirror) and enter CDN url. But, it only replaces the first url. Could you please check and fix this issue!
Great plugin!
Thank you very much!
-
Hello @stormit
Thank you for your inquiry and I am happy to assist you with this.
Can you please share some more details about this?
Which CDN are you using? Are you using multisite?
What is the expected behavior?
Thanks!Hi @vmarko,
I use keyCDN. I’m not using multisite.
For example:
– Our site url is: https://mysite.com/
– Our CDN url is: mycdn.com (Zone URL)My image link: https://mysite.com/image-1.jpg will become https://mycdn.com/image-1.jpg
My html is:
<div data-urls="https://mysite.com/image-1.jpg,https://mysite.com/image-2.jpg,https://mysite.com/image-3.jpg"></div>Only the first url is replaced. It looks like below
<div data-urls="https://mycdn.com/image-1.jpg,https://mysite.com/image-2.jpg,https://mysite.com/image-3.jpg"></div>Thank you very much!
Hello @stormit
Thank you for the information.
Can you please share your website URL so I can check this?
Thanks!Hi @vmarko,
You can check it here: http://demo.theme-sky.com/upstore-furniture/
Link screenshot: https://prnt.sc/t6trf1
Thank you very much!
Hello @stormit
As I can see those images are on the CDN and served by the CDN:
http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-4.jpg
http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-3.jpg
http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-1.jpgIt only appears that way because of the HTML output and the <div> structure.
Thanks!Hi @vmarko,
You may not understand what I want. I want all urls to be replaced by CDN. HTML should be:
data-background_images="http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-3.jpg,http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-1.jpg,http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-2.jpg,http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-5.jpg,http://demothemesky-be87.kxcdn.com/upstore-furniture/wp-content/uploads/2018/04/bg-4.jpg"But your plugin only replaces the first URL. Please check it again!
Best regards,
Hello @stormit
Those images are most likely added to your page by some JavaScript code. We cannot scan JS for image URLs and replace them, so that’s why they’re not loaded from the CDN.
As you can see in the previous post, the images are uploaded to the CDN but because of the way they are added to your page they are not showing served from the CDN.
Thanks!Hi @vmarko,
They are not added by Javascript. They are added by PHP. Did you try adding it by yourself?
I know images exist on CDN. But, your plugin does not replace all urls. So, it still loads images from our hosting. That is problem.
Please check your plugin again!
Thank you very much!
-
This reply was modified 5 years, 11 months ago by
Stormit.
Hello @stormit
Let me try to test and replicate this and I’ll get back to you with the results.
Thanks!Hello @stormit
Thank you for your patience. We checked and tested this and this only happens when those are delivered by js/ajax.
These images should dynamically after the page is processed by W3TC. Your server sends the fully-composed HTML back to the browser and then the JavaScript executes and downloads those files from your primary domain.
There’s a hook, in that case, to add to the code generating content: wp_prepare_attachment_for_jsYou can also try changing the URLs for those images manually to use the CDN version.
Thank you!Hi @vmarko,
As I said they are not added by JS. They are added by PHP. Don’t care about loading images after page is loaded. It just read image urls in data-background_images and load images based on those urls. But all urls in data-background_images are not replaced. Only the first url is replaced. They are replaced by your plugin. That is why I contacted you :). Please check again!
Thank you very much!
-
This reply was modified 5 years, 11 months ago by
Stormit.
-
This reply was modified 5 years, 11 months ago by
The topic ‘CDN – List URLs’ is closed to new replies.