Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: heavyccasey in Februar 15, 2009, 03:13:17 VORMITTAG

Titel: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Februar 15, 2009, 03:13:17 VORMITTAG
Here's a quick and simple way to display a link instead of an image in a quote, without hiding smileys (http://www.simplemachines.org/community/index.php?topic=30209.0) or complicated regular expressions (http://custom.simplemachines.org/mods/index.php?action=search;basic_search=image+quote):

This is tested for 1.1.5 - 1.1.8, as well as 2.0 RC1, although older 1.1 versions will probably work too.


Subs.php
Find:
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(


Add Before:
// Remove images from quotes.
array(
'tag' => 'img',
'type' => 'unparsed_content',
'require_parents' => array('quote'),
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<i>(<a href="$1" target="_blank" onclick="this.parentNode.innerHTML = \'<i\' + \'mg src=\\\'\' + this.href + \'\\\' /\' + \'>\'; return false;">Image removed from quote</a>.)</i>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'require_parents' => array('quote'),
'content' => '<i>(<a href="$1" target="_blank" onclick="this.parentNode.innerHTML = \'<i\' + \'mg src=\\\'\' + this.href + \'\\\' /\' + \'>\'; return false;">Image removed from quote</a>.)</i>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),



Instead of an image, it'll look like...

Zitat(Image removed from quote (#post_dontclick).)
...and when you click it, the image will appear. No JavaScript, no problem! In that case, it'll open a new tab/window with the image.

You can mess with the HTML ('content' => '<i>...</i>',) if you want. Just don't touch the Javascript, it's hell trying to figure out how to properly escape the quotes.  :P

That's it!
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 03:17:13 VORMITTAG
Nice. Can you do the same for RC1?
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: SA™ in Februar 15, 2009, 03:35:53 VORMITTAG
aint that pretty much the same as my mod

http://custom.simplemachines.org/mods/index.php?mod=1302
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Februar 15, 2009, 03:38:09 VORMITTAG
Zitat von: Antechinus in Februar 15, 2009, 03:17:13 VORMITTAG
Nice. Can you do the same for RC1?
I don't know, I don't have a copy of RC1 installed.

I downloaded a copy of the source... the parse_bbc() array looks almost exactly the same as 1.1. I think the same code would work for 2.0, but I don't have anything to test on. Would you mind testing it? I'm almost certain it'll work.

Zitat von: wdm2005 in Februar 15, 2009, 03:35:53 VORMITTAG
aint that pretty much the same as my mod

http://custom.simplemachines.org/mods/index.php?mod=1302
Yes. In fact, I linked to it in my post. However, yours includes complicated regular expressions while this tip uses the SMF-included BBC manager.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 03:45:06 VORMITTAG
Also this gives a hide/show option. I'm not sure if the mod does the same (because I haven't tested it) but it's a handy feature.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Marcus Forsberg in Februar 15, 2009, 03:47:50 VORMITTAG
Moved to Tips and Tricks (http://www.simplemachines.org/community/index.php?board=72.0) and added to Tips and Tricks (index) (http://www.simplemachines.org/community/index.php?topic=15899.0). Thanks for your tip.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 04:36:48 VORMITTAG
Doesn't appear to work in RC1.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Februar 15, 2009, 05:04:55 VORMITTAG
Zitat von: Antechinus in Februar 15, 2009, 04:36:48 VORMITTAG
Doesn't appear to work in RC1.
Fixed in original post. Thanks for testing! Apparently SMF 2.0 doesn't automatically put in image dimensions anymore.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 05:15:47 VORMITTAG
Yep, that works. Good job. :)

ETA: Prefer it in non-italic myself but that's easy to sort if anyone wants to.

In fact I think I'll install this on my forum right now. I get sick of people quoting the same damned image just to post a one line response. 
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Februar 15, 2009, 05:22:07 VORMITTAG
If you don't want the italics, you'd better replace <i></i> with <span></span> instead of just removing it, if you haven't already figured that out.

Drives me crazy too :P
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 05:32:09 VORMITTAG
It works without the <span></span>. Dunno if it's supposed to but it does.

ETA: Validates that way too. No html or css or js errors. Go figure.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Februar 15, 2009, 05:46:17 VORMITTAG
Zitat von: Antechinus in Februar 15, 2009, 05:32:09 VORMITTAG
It works without the <span></span>. Dunno if it's supposed to but it does.

ETA: Validates that way too. No html or css or js errors. Go figure.
It just looks like it's working. If you add text before or after the image, without the <span>, the text disappears too.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in Februar 15, 2009, 05:58:51 VORMITTAG
Ah. I see what you mean. The text displays fine until you click the link to show the image. I added the span tags and as you say that sorts it.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Chas Large in August 11, 2009, 03:32:00 NACHMITTAGS
Thanks for this tip, the mod works just fine in 1.1.10.
Chas
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Simplemachines Cowboy in August 11, 2009, 05:13:07 NACHMITTAGS
Cool. Works nicely on 1.1.10.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: bbmtalk in September 04, 2009, 12:23:53 VORMITTAG
Can this be done to resize the image to 300 pixels in quotes if the image is larger than 300 pixel?
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in September 05, 2009, 05:47:33 NACHMITTAGS
Not without a lot of work. At that point the script does not know how big the image is, and won't without downloading it. At best you could make it scrollable, or else you'd have to enforce it go determine how big it is first.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: chrlsnicholas7 in September 15, 2009, 05:31:12 NACHMITTAGS
Can we increase the pixel size if it is smaller than 100...
Will the clarity be maintained....
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in Oktober 11, 2009, 05:48:17 VORMITTAG
This is currently available as a mod: http://custom.simplemachines.org/mods/index.php?mod=1302
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: heavyccasey in Oktober 11, 2009, 06:46:36 NACHMITTAGS
That mod uses its own regular expression code, while this edit uses the built-in SMF system.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in Oktober 11, 2009, 06:50:51 NACHMITTAGS
Ah, my bad. I just figured the two used the same method - I didn't check, but it's usually the case that if a mod is written where there is an existing tip/trick, that the mod may well have used the code from the tip.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: nwobhm in November 14, 2009, 01:37:53 NACHMITTAGS
Has anyone tried if this works with RC2 :)
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in November 14, 2009, 01:47:43 NACHMITTAGS
I see no reason why this wouldn't work on 2.0 RC2. The BBcode listing wasn't touched IIRC.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in November 14, 2009, 08:08:51 NACHMITTAGS
I'll definitely be wanting this on RC2 so if it doesn't work now I'll find a way to make sure it does (if nobody beats me to it). AFAIK though it should work.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Costa in November 14, 2009, 08:13:22 NACHMITTAGS
This work on RC2!
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Scratching my Head in März 10, 2010, 03:59:46 NACHMITTAGS
Does not appear to work for 1.1.11  :-[
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in März 10, 2010, 04:03:03 NACHMITTAGS
No, there was a rewrite of the img tag in 1.1.11.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Scratching my Head in März 10, 2010, 04:09:06 NACHMITTAGS
Thanks Arantor. Is there a fix/mod that achieves the desired result?
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in März 10, 2010, 04:09:33 NACHMITTAGS
Nope, it's a complete rewrite of the tip :S
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Scratching my Head in März 10, 2010, 04:12:14 NACHMITTAGS
I'm not sure I follow. As I understand it there is nothing now available that hides images in quotes?
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Arantor in März 10, 2010, 04:14:18 NACHMITTAGS
Correct. The tip is based on the old img tag code that was in versions prior to 1.1.11. It will need rewriting to work on 1.1.11.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Scratching my Head in März 10, 2010, 04:16:42 NACHMITTAGS
Very good. Thanks muchly, Arantor.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.mysmiley.net%2Fimgs%2Fsmile%2Fsign%2Fsign0201.gif&hash=38d538ff0608d275cebaac8ba7dd76d9a77813e5)
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: gbsothere in März 10, 2010, 04:21:06 NACHMITTAGS
Zitat von: Arantor in März 10, 2010, 04:14:18 NACHMITTAGS
Correct. The tip is based on the old img tag code that was in versions prior to 1.1.11. It will need rewriting to work on 1.1.11.



I've used the old Remove Images From Quote mod v1[1].0 for a long time; we have it now on my 1.1.11 board.  I can't remember, but I don't think I had to tweak anything for it to work. 

:-\

But then, I don't remember what I had for lunch, so....

:)

Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Chas Large in März 10, 2010, 04:48:15 NACHMITTAGS
I've written a mod for SMF 2.0 RC2 based on this tip but it's not been approved yet.

It also works for RC3.

It's title will be "Remove images from Quotes" I'll post here again when it's released.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: gbsothere in März 10, 2010, 05:12:48 NACHMITTAGS
Zitat von: Scratching my Head in März 10, 2010, 04:35:14 NACHMITTAGS
Doesn't appear to work for 1.1.11

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.postimg.com%2F13000%2F12012.jpg&hash=58625dbb6c0ed6dc9db4d8a1e4b596e77fa33d27)




Pic of it working for 1.1.11

:)

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwhereitestmystuff.com%2Fimages%2Fquote.jpg&hash=1cec71d6e4c7b915dd1186aea82dd086c36fa268)

Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: Antechinus in März 11, 2010, 03:46:36 VORMITTAG
Works in 1.1.11 for me too. Never changed a thing.

In fact I want to tweak it to remove the quotes from quotes. :D Having quotes collapsed by default and expandable onclick would be rather handy I think.
Titel: Re: [Tip] Remove Images from Quotes!
Beitrag von: waruna in März 11, 2010, 06:44:31 VORMITTAG
I'm using SMF2.0 RC2. Just a quick question, is there any way to remove images from quotes only at the same page of the images? I mean the function will not work if the images are quoting from another page.

Thanks in advance.