adit
adit

Reputation: 33674

using amazon s3 to host static image and referencing from css

So I am trying to use s3 to upload all static images/css/js that I have. In one of my css file which is inside a css folder, I have the following:

background: url('../bundles/sitemain/img/bg-storefront.png') no-repeat center top;

and in my s3 bucket I already have the bundles folder:

enter image description here

With the file bg-storefront.png in the appropriate sub directory. However, is this even possible with amazon s3 such that it doesn't have the notion of what a folder is. So in this case do I have to use the absolute path of the image to make it work?

Upvotes: 0

Views: 3144

Answers (1)

fyhuang
fyhuang

Reputation: 2187

Using the relative path should work: when the browser interprets the parent directory .., it does it simply by how the URL looks. The browser/website visitor doesn't normally know anything about the actual file structure behind most web pages, and S3 is no different. If your CSS file is named css/style.css and you reference ../bundles/images/a.png, it only matters (to the browser) that the URL bundles/images/a.png exists: it doesn't matter whether a real filesystem or directory structure backs up those URLs.

Upvotes: 1

Related Questions