The Un-Official Proxomitron Forum
"Image Like opera" with black and white list? - Printable Version

+- The Un-Official Proxomitron Forum (https://www.prxbx.com/forums)
+-- Forum: Proxomitron Filters (/forumdisplay.php?fid=38)
+--- Forum: Filter Help/Request (/forumdisplay.php?fid=31)
+--- Thread: "Image Like opera" with black and white list? (/showthread.php?tid=1085)



"Image Like opera" with black and white list? - Guest - Aug. 31, 2008 04:10 PM

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


RE: "Image Like opera" with black and white list? - Kye-U - Aug. 31, 2008 05:42 PM

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.


RE: "Image Like opera" with black and white list? - Guest - Aug. 31, 2008 08:50 PM

Got it! Working great
Thanks a lot


RE: "Image Like opera" with black and white list? - ProxRocks - Sep. 01, 2008 12:18 AM

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?


RE: "Image Like opera" with black and white list? - Kye-U - Sep. 01, 2008 06:01 AM

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>"



RE: "Image Like opera" with black and white list? - ProxRocks - Sep. 01, 2008 12:58 PM

doh! sorry 'bout that, i should have caught the .gif-bit, lol...

thanks again...