Solved

Prevent image downloading via css

Posted on 2009-06-29
6
977 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

734 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