Jump to content

CDN and images


jonniejoejonson

Recommended Posts

I have a website that allows users to upload their own images...

the images will get uploaded to my server at...

www.mydomain.com/images/

 

I curently refernce an image as:

<?php

print'<img src="images/'.$filename.'"/>';

?>

 

But if i wanted to use a CDN,

1. How would i reference the image so that it is displays the CDN image?.. bearing in mind i assume a CDN has multiple servers and multiple subdomains... so how to know which subdomain/server to reference to.

 

2. Would i need to store the subdomain(CDN location) of the image in a database along with the fielname and reference like this?

<?php

print'<img src="'.$cdn_subdomain.'/images/'.$filename.'"/>';

?>

or does a cdn just automatically reference all images?

 

 

Link to comment
https://forums.phpfreaks.com/topic/242832-cdn-and-images/
Share on other sites

I know this isn't much of an explanation, but without reading your specific CDN manual, i have to say: that will depend on the service you get. Such questions should be answered in your CDN manual.

I have used CDN's in the past, that allowed me to upload singe images, or entire folders, if images where uploaded in a folder, then I would reference them with <CDN URL>/<FOLDER NAME>/<IMAGE NAME>, if I had just dumped them freely into the root, I would just use <CDN URL>/<IMAGE NAME>.

 

 

Link to comment
https://forums.phpfreaks.com/topic/242832-cdn-and-images/#findComment-1247323
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.