Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prevent image downloading via css

Posted on 2009-06-29
6
Medium Priority
?
984 Views
Last Modified: 2013-12-25
I have a webpage that is built using a rss feed.  This rss feed contains alot of images and stuff I don't want to use / show, so I use css to 'display:none'  on certain tags to not show some images.   The problem is these images are still downloaded via the browser.  Does anyone know how to prevent the browser from downloading these images via css?  I've tried both 'display:none' and 'visibility:hidden' on IE7/8 with no luck.   Thanks
0
Comment
Question by:ericsama
  • 2
  • 2
  • 2
6 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24739762
If you want to prevent them to be download then don't put them in the RSS in the first place. You can also change the URL such that the server understands it  comes from an RSS request, but then you'd still have a roundtrip and you'd have to instruct your server to return with an "empty" image.

The original question: using CSS to prevent downloading, is not possible.

If you'd load the RSS through javascript, for instance with an XHR object and then post-process them by hand you have all the control on what part you include and what not. But I don't know how the RSS is used and whether you have control over that process at all. The easiest is just to leave it out of the RSS to begin with...
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 24740041
As I read it the RSS feed is not yours but you are accessing it to add content to your own site or something similar via your own browser? If this is correct, you want to stop loading the images to save bandwidth? If this is also the case, you can block the host of the RSS feed to not fetch any more images.

This can be done in Firefox (but probbaly also in IE in a similar method) like this:
right click the image and select 'block images from IP'.

Hope this helps...
0
 

Author Comment

by:ericsama
ID: 24741030
Yes, its a 3rd party RSS feed.  The page is built using this RSS feed so I'm pretty sure the only way to solve this is if there's a way via css so the browser doesn't load the hidden images (which are being hidden by css 'display:none').  I also use some of these images on secondary pages so I don't want to use / write a custom feed reader to disregard them.  These secondary pages only get a little traffic, the home page gets a ton and that's where its downloading a bunch of images that I don't display.  
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 39

Accepted Solution

by:
abel earned 1500 total points
ID: 24741161
> I'm pretty sure the only way to solve this is if there's a way via css so the browser doesn't load the hidden images
Why? If you can control the CSS, you can also control the page, can you not? Just change the way the page is rendered. And really, CSS can not be used for preventing to download an image. It is not meant for it, and it has no means for it.

Once the RSS is in HTML it will download the images, whatever you put in CSS. The reason is simple: it needs to image, then it applies the rules from CSS to that image (i.e., height, width, display:block, none etc).

In short, to prevent downloading them, if you can control the CSS I assume you can control the rendering to HTML as well., or better yet, the retrieval of the RSS stream, in which case you can filter it away.

-- Abel --
0
 
LVL 13

Expert Comment

by:Onthrax
ID: 24742710
If you require a second opinion, abel is correct. CSS is used for styling and cannot change functionality.

And as Abel says, you could filter out the images when reading the RSS feed before displaying it. Which programming language are you using?
0
 

Author Closing Comment

by:ericsama
ID: 33091947
best answer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question