Solved

Prevent image downloading via css

Posted on 2009-06-29
6
973 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 39

Accepted Solution

by:
abel earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

825 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