Advertisement:

Author Topic: [Tip] Remove Images from Quotes!  (Read 35862 times)

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
[Tip] Remove Images from Quotes!
« on: February 15, 2009, 03:13:17 AM »
Here's a quick and simple way to display a link instead of an image in a quote, without hiding smileys or complicated regular expressions:

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:
Code: [Select]
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(

Add Before:
Code: [Select]
// 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...

Quote
(Image removed from quote.)
...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!
« Last Edit: February 15, 2009, 05:05:15 AM by heavyccasey »

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #1 on: February 15, 2009, 03:17:13 AM »
Nice. Can you do the same for RC1?

Offline SA™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,955
  • (T)ogether (E)veryone (A)chieves (M)ore
    • DenotsNiaga on Facebook
    • SAChatBar
Re: [Tip] Remove Images from Quotes!
« Reply #2 on: February 15, 2009, 03:35:53 AM »
aint that pretty much the same as my mod

http://custom.simplemachines.org/mods/index.php?mod=1302
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
Quote
My allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: [Tip] Remove Images from Quotes!
« Reply #3 on: February 15, 2009, 03:38:09 AM »
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.

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.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #4 on: February 15, 2009, 03:45:06 AM »
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.

Offline Marcus Forsberg

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,608
  • Gender: Male
    • marcus.t.forsberg on Facebook
    • marcusforsberg on LinkedIn
    • @marcusforsberg on Twitter
    • marcusforsberg.net
Re: [Tip] Remove Images from Quotes!
« Reply #5 on: February 15, 2009, 03:47:50 AM »
Moved to Tips and Tricks and added to Tips and Tricks (index). Thanks for your tip.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #6 on: February 15, 2009, 04:36:48 AM »
Doesn't appear to work in RC1.

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: [Tip] Remove Images from Quotes!
« Reply #7 on: February 15, 2009, 05:04:55 AM »
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.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #8 on: February 15, 2009, 05:15:47 AM »
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. 
« Last Edit: February 15, 2009, 05:18:31 AM by Antechinus »

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: [Tip] Remove Images from Quotes!
« Reply #9 on: February 15, 2009, 05:22:07 AM »
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

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #10 on: February 15, 2009, 05:32:09 AM »
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.

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: [Tip] Remove Images from Quotes!
« Reply #11 on: February 15, 2009, 05:46:17 AM »
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.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: [Tip] Remove Images from Quotes!
« Reply #12 on: February 15, 2009, 05:58:51 AM »
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.
« Last Edit: February 15, 2009, 06:00:31 AM by Antechinus »

Offline Chas Large

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,101
  • Gender: Male
  • Running 2.0.xx on Apache.
    • Chas.Large on Facebook
    • https://www.linkedin.com/in/charles-large-568ba213 on LinkedIn
    • @https://twitter.com/ on Twitter
    • Chas Large's Site
Re: [Tip] Remove Images from Quotes!
« Reply #13 on: August 11, 2009, 03:32:00 PM »
Thanks for this tip, the mod works just fine in 1.1.10.
Chas
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Offline Simplemachines Cowboy

  • Jr. Member
  • **
  • Posts: 354
  • KA-CLICK
    • The Open Range
Re: [Tip] Remove Images from Quotes!
« Reply #14 on: August 11, 2009, 05:13:07 PM »
Cool. Works nicely on 1.1.10.
My SMF forum: The Open Range

Offline bbmtalk

  • Jr. Member
  • **
  • Posts: 236
Re: [Tip] Remove Images from Quotes!
« Reply #15 on: September 04, 2009, 12:23:53 AM »
Can this be done to resize the image to 300 pixels in quotes if the image is larger than 300 pixel?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,032
    • Arantor on GitHub
Re: [Tip] Remove Images from Quotes!
« Reply #16 on: September 05, 2009, 05:47:33 PM »
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline chrlsnicholas7

  • Newbie
  • *
  • Posts: 1
Re: [Tip] Remove Images from Quotes!
« Reply #17 on: September 15, 2009, 05:31:12 PM »
Can we increase the pixel size if it is smaller than 100...
Will the clarity be maintained....

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,032
    • Arantor on GitHub
Re: [Tip] Remove Images from Quotes!
« Reply #18 on: October 11, 2009, 05:48:17 AM »
This is currently available as a mod: http://custom.simplemachines.org/mods/index.php?mod=1302
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: [Tip] Remove Images from Quotes!
« Reply #19 on: October 11, 2009, 06:46:36 PM »
That mod uses its own regular expression code, while this edit uses the built-in SMF system.