Post Reply 
"Image Like opera" with black and white list?
Aug. 31, 2008, 04:10 PM
Post: #1
"Image Like opera" with black and white list?
Name = "$LST(NoImages): Image to Link"
Active = TRUE
Multi = TRUE
URL = "$LST(NoImages)"
Bounds = "<img\s*.(jpg|png|bmp)*>"
Limit = 512
Match = "<img*src=\"\2\"[^>]+>"
Replace = "<a href=\"\2\" target=\"_blank\">[I]</a>"

Hi, I've been using this filter for some time but I have some questions

I'd like to replace the link with the "alt" text in images. But sometimes there is no alt text and sometimes the texts are too long. Is there a better way to deal with the alt text replacement?
For example, if there is no alt, replace it with text "image" .
And if text too long, trim it to 10 characters...

I'm using the list $LST(NoImages) for sites that I want to block images now.
Can I use a URL white list and a black list together.
If yes, how should it be?

Thanks
Quote this message in a reply
Aug. 31, 2008, 05:42 PM
Post: #2
RE: "Image Like opera" with black and white list?
Here you are Smile!

Code:
[Patterns]
Name = "$LST(NoImages): Image to Link"
Active = TRUE
Multi = TRUE
URL = "$LST(NoImages)"
Bounds = "<img\s*.(jpg|png|bmp)*>"
Limit = 512
Match = "<img(*src=$AV(\2)&(*(alt|title)=$AV((?+{1,10})\3)|))[^>]+>((^$TST(\3=*))$SET(3=[I])|)"
Replace = "<a href=\"\2\" target=\"_blank\">\3</a>"

If there is no ALT or TITLE attribute, it will simply set the link text to I, in square brackets. It will also trim the ALT/TITLE text to 10 characters.

If you want it to display "Image", just change:

Code:
((^$TST(\3=*))$SET(3=[I])|)

To:

Code:
((^$TST(\3=*))$SET(3=Image)|)

As for using a white and blacklist together, I think you'll have to choose only one since using both at the same time would conflict.
Visit this user's website
Add Thank You Quote this message in a reply
Aug. 31, 2008, 08:50 PM
Post: #3
RE: "Image Like opera" with black and white list?
Got it! Working great
Thanks a lot
Quote this message in a reply
Sep. 01, 2008, 12:18 AM
Post: #4
RE: "Image Like opera" with black and white list?
cool!...

i'm having a problem getting it to convert images to links for "cursed" sites that fill their <img> tags with 'white space'...

Code:
<img
                     src="/br_static/generic-billfinder/images/goscout_enroll_button.gif"
                     alt="Link to sign up for MyCheckFree" width="245" height="60" border="0">

Code:
<img src="/br_static/generic-billfinder/images/emp_v3.gif" alt="Emergency Payments"
                          align="right" border="0" width="300" height="250">

both from here - (half-SSL'ed link), http://https-px-.mycheckfree.com/br/wps


can the above work for those two .gif's?
Add Thank You Quote this message in a reply
Sep. 01, 2008, 06:01 AM
Post: #5
RE: "Image Like opera" with black and white list?
The filter only worked for jpg, bmp and png files; I've made it so it supports jpeg and gif files as well, and also added "..." to truncated alt/title attributes:

Code:
[Patterns]
Name = "$LST(NoImages): Image to Link"
Active = TRUE
Multi = TRUE
URL = "$LST(NoImages)"
Bounds = "<img\s*.(jp(e|)g|png|bmp|gif)*>"
Limit = 512
Match = "<img(*src=$AV(\2)&(*(alt|title)=$AV((?+{1,10})\3)|))[^>]+>((^$TST(\3=*))$SET(4=[I])|$SET(4=\3...))"
Replace = "<a href=\"\2\" target=\"_blank\">\4</a>"
Visit this user's website
Add Thank You Quote this message in a reply
Sep. 01, 2008, 12:58 PM
Post: #6
RE: "Image Like opera" with black and white list?
doh! sorry 'bout that, i should have caught the .gif-bit, lol...

thanks again...
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: