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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.