Page 1 of 1

Blocking images that are not linked to a jpg

Posted: Mon Jun 09, 2008 9:38 pm
by james
I was wondering if all (or most) images on a page (background images, unlinked images, and images linked to other than a jpg) can be blocked from a page, allowing only images that are linked to a jpg file. Thanks.

Re: Blocking images that are not linked to a jpg

Posted: Tue Jun 10, 2008 11:39 pm
by Adblock Plus Fan
james wrote:unlinked images, and images linked to other than a jpg
I imagine something like this should work:

Code: Select all

domain.com##IMG:not(A[href$=".jpg"] > IMG)
Except, it doesn't work ^^;;

Wladimir, or someone else, can you explain why this doesn't work?

Posted: Mon Jun 16, 2008 7:20 am
by Wladimir Palant
:not() is very limited in what it can do. If you look at http://www.w3.org/TR/css3-selectors/#negation - only simple selectors can be used, meaning especially that no compound selectors are accepted here (mostly for performance reasons).

In userContent.css one could write something like this (note that the link isn't necessarily a direct parent of the image):

Code: Select all

@-moz-document domain(domain.com)
{
  img
  {
    display: none;
  }

  a[href $= ".jpg"] img
  {
    display: inline;
  }
}
You can also add this snippet of CSS code to Stylish. Adblock Plus isn't that flexible however.