Author Topic: Remove Image Borders  (Read 14961 times)

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« on: April 22, 2002, 08:22:27 PM »
This filter will remove image borders (sets them to border=0) while preserving most other img tag attributes. It works even if the border attribute is missing. This is an adaptation of an example from the help files.



Name = "Remove Image Borders"
Active = TRUE
Bounds = "<imgs*>"
Limit = 256
Match = "(*((align|alt|class|controls|dir|dynsrc|height|hspace|id|"
        "ismap|lang|longdesc|loop|lowsrc|name|onclick|ondblclick|"
        "onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|"
        "onmouseout|onmouseover|onmouseup|src|start|style|title|"
        "usemap|vspace|width)((=$AV(*))|) )#)+ *"
Replace = "<img @ border="0">"



If there are attributes missing that you need you'll have to add them. Remove any you don't want.


Facing each other,
a thousand miles apart.

altosax

  • Sr. Member
  • ****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Remove Image Borders
« Reply #1 on: April 22, 2002, 10:28:48 PM »

hi hpguru,
i'm puzzled: why to remove the border from an image you have to match all other attributes?

perhaps i haven't understood in deep your filter, please explain it to me.

in the meantime, i suggest
Bounds = "<im(g|age)s*>"

sincerely,
altosax.


 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« Reply #2 on: April 23, 2002, 12:38:22 AM »
I tried several filters and that is the only single filter that worked reliably.
This filter pushes all the existant attributes listed onto the replacement stack when matched. Attributes not listed (such as border) are not matched so they don't get pushed to the stack and are lost in the subsequent replacement.
In the replacement "@" dumps all the attributes stored in the replacement stack to the replacement string and the desired border attribute is inserted. This way border is added only once whether it exists or not and irregardless of it's position within the img tag. It acomplishes what it took two filters to do before.

I don't use "<im(g|age)s*>" because I've never seen an "<image>" tag used anywhere. I can't find any documentation of such a tag.



Edited by - hpguru on 23 Apr 2002  02:04:16
Facing each other,
a thousand miles apart.

Jor

  • Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Remove Image Borders
« Reply #3 on: April 23, 2002, 02:00:17 AM »
<image> is a MicroSoft "innovation" which appeared on their website before they moved to XML. The probable reason: this way download buttons for patches were invisible in all non-IE browsers.

Alas it was taken up by some idiots, as Frontpage accepts it (and I believe some versions even use it instead of <img>). I've seen it a couple of times on other sites... fortunately it doesn't seem to be as wide-spread as other MS or NS "extensions" of HTML.

 
 

Jor

  • Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Remove Image Borders
« Reply #4 on: April 23, 2002, 02:11:55 AM »
Wouldn't this filter:
Name = "Remove Image Borders"
Active = TRUE
Bounds = "<im(g|age)s*>"
Limit = 256
Match = "1 border=$AV(*) 2"
Replace = "1 border="0" 2"
work just as well? No need to add border="0" to all images... since the default is none.

 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« Reply #5 on: April 23, 2002, 02:31:13 AM »
quote:

<image> is a MicroSoft "innovation"...


That's what I presumed but I couldn't find mention of it at

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp

I always investigate when I find an ad that wasn't blocked and this tag never showed up. Even if I do find it I doubt I'll modify my filters to accomidate it unless I think I'll be returning to the site frequently. Even then I may not do it since eDexter zaps almost all the ads. Even if I go *proxyless* I see no ads, just blank areas and a few outlines here and there.

Anyway this filter I posted is a little on the bulky side so when I find a better way to do it cleanly I'll post it.

 
Facing each other,
a thousand miles apart.

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« Reply #6 on: April 23, 2002, 02:35:37 AM »
quote:

... since the default is none.


Yes but if the image is a link the browser draws a border. Err ahh IE and Netscape draw a border. Opera doesn't.

That filter won't match if the border attribute is missing.




Edited by - hpguru on 23 Apr 2002  03:44:47
Facing each other,
a thousand miles apart.

Jor

  • Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Remove Image Borders
« Reply #7 on: April 23, 2002, 02:38:33 AM »
It's never been documented, which adds to my suspicion it's only intended use was to disable users of other browsers from downloading critical bugfixes (patches, and service packs, as MS calls them).

BTW, can ANYONE open these MSDN urls from within Opera? No matter what config I try (Prox on, Prox off, Prox web bypassed, Prox headers bypassed, etc) I only see the following:
"Welcome to the MSDN Library
Component Development
Data Access
Development (General)
Enterprise Development
Graphics and Multimedia
Messaging and Collaboration
Mobile and Embedded Development
.NET Development
.NET Development
Networking and Directory Services
Office Solutions Development
Security
Security
Setup and System Administration
User Interface Design and Development
User Interface Design and Development
Visual Tools and Languages
Web Development
Windows Development
XML Web Services
XML Web Services
MSDN Library Archive"

These URLs are really the only sites I still need MSIE for.

Edited by - Jor on 23 Apr 2002  03:41:11
 

Jor

  • Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Remove Image Borders
« Reply #8 on: April 23, 2002, 02:40:34 AM »
quote:

Yes but if the image is a link the browser draws a border.

It does? *L* Been a long while since I used MSIE as my default browser... Opera allows for full control over this. (Preferences -> Fonts and Colors -> My Link Style -> Always border on image links). I have it set for disabled.

 
 

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Remove Image Borders
« Reply #9 on: April 23, 2002, 02:52:02 AM »
I had that same problem with MSDN pages with IE6 as well. I ended
up putting msdn.microsoft.com in my bypass list temporarily to
make it work. I never got around to looking at their site to see
why that was happening.

 
 

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Remove Image Borders
« Reply #10 on: April 23, 2002, 03:03:55 AM »
I just checked why those MSDN pages don't load: it's the User-Agent
HTTP header value. Try changing Opera's Browser Identification value
to an MSIE value and I bet it works!

 
 

Jor

  • Moderator
  • Sr. Member
  • *****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Remove Image Borders
« Reply #11 on: April 23, 2002, 03:13:12 AM »
Thank you!

That's it... and MS also seems to accept Mozilla user agents. I've added it to my DumbSites list... and will send a complaint to them some time tomorrow ^.^

 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« Reply #12 on: April 23, 2002, 03:29:55 AM »
quote:

I had that same problem with MSDN pages with IE6 as well. I ended
up putting msdn.microsoft.com in my bypass list temporarily to
make it work. I never got around to looking at their site to see
why that was happening.





Same here. I need the info more than I need to pick their site apart so they are in the bypass. :( Realistically though, MS didn't write those pages for any other browser but IE and unfortunately that is the only browser that will render them correctly.

 
Facing each other,
a thousand miles apart.

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Remove Image Borders
« Reply #13 on: August 22, 2002, 05:17:46 AM »
I made a few changes to my new Remove Image Borders filter and decided to move it here.


Name = "Remove Image Borders v2.1"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)"
Bounds = "<imgs*>"
Limit = 300
Match = "((border=$AV(0)>)1)|((border=$AV(0)s)1 2)"
        "|((border=$AV([#1:10])>)$SET(1=border="0")$SET(2=>))"
        "|((border=$AV([#1:10])s)$SET(1=border="0" ) 2)"
        "|(>)$SET(1= border="0")$SET(2=>)"
Replace = "12"


Can anyone think of a way to make it fail to match in the bounds match if border="0" already exists?

Facing each other,
a thousand miles apart.
Facing each other,
a thousand miles apart.

altosax

  • Sr. Member
  • ****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Remove Image Borders
« Reply #14 on: August 22, 2002, 10:27:03 AM »
hi hp,
why not the filter jor proposed?

also, read my post in the if-then-else thread.

altosax.