Solved

Prevent image downloading via css

Posted on 2009-06-29
6
970 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now