[ALPHA] Prevent Quote Image Mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply
Cyberpenguin
Registered User
Posts: 14
Joined: Fri Nov 26, 2004 8:28 am

[ALPHA] Prevent Quote Image Mod

Post by Cyberpenguin »

Well, this is my first attempt at a mod, and it fixed a major thing that was bugging me. Basicly, when a user quotes an image (may happen many times in 1 thread) the page loads the image again for the new quote, using bandwidth, taking longer to load, and increasing the size of the page. Well this mod will fix that by removing the image from quoted posts, and instead replacing it with the text link to the image, therefore saving space, bandwidth, and load time!

Its fairly straightfoward... suggestions are appreciated!

Code: Select all

##############################################################
## MOD Title: Prevent Quote Image Mod
## MOD Author: Matt (aka Cyberpenguin) < mschettler@earthlink.net > http://www.clancybr.com/
## MOD Description: This mod will replace an quoted image with the text link,
##                  instead of displaying the image again (saves bandwidth and pagespace!)
## MOD Version: 0.0.1
## Installation Level: Easy
## Installation Time: ~1 minutes
## Files To Edit:    1
##         viewtopic.php
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php

#
#
#-----[ FIND ]------------------------------------------------
# 

$message = str_replace("\n", "\n<br />\n", $message);

#
#-----[ AFTER, ADD ]------------------------------------------
# 

	//
	//Prevent Quote Image Mod
	//
	
	print "<!-- " . "Quote Image Mod by Cyberpenguin www.ClanCybr.com" . " -->";

	$x = strpos($message,"<td class=\"quote\">");
	$y = strpos($message,"</td>",$x);

	$quotetext = substr($message,$x, $y - $x);

	if (!$quotetext == "") {

		$a = strpos($quotetext,"<img src=");
		$b = strpos($quotetext," border=\"0\" />",$a);
	
		$imagesource = str_replace("\"","",str_replace("<img src=","",substr($quotetext,$a,$b - $a)));

		$quotetext = str_replace("<img src=\"" . $imagesource . "\" border=\"0\" />", "<a href=\"" . $imagesource . "\">" . $imagesource . "</a>",$quotetext);

		$message = substr($message,0,$x) . $quotetext . substr($message,$y);

	}

	//
	//Prevent Quote Image Mod
	//

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM 
Demo: Here!
User avatar
onigumo
Registered User
Posts: 1755
Joined: Fri Oct 31, 2003 2:32 am
Contact:

Post by onigumo »

I know of another one that's supposed to perform this same function, but it didn't work, for me, at least. This one's more simple to implement, if I'm correct, as it's one simple addition to put into a file instead of several, as the other one was. I hope this one works. I'll be trying it out later, and I look forward to a speedy release, though I might be surprised.
I write articles on community building
@ The Infinity Program.
ultima528
Registered User
Posts: 100
Joined: Tue Apr 06, 2004 8:24 pm

Post by ultima528 »

Thats weird, when my browser loads an image, and there's another reference to the same image on the same page, it doesn't download it again. It just places a copy of the image in the second+ locations on the page.

Like...

Code: Select all

.---------------------.
| Image1       Image2 |
| Image3       Image1 |
'---------------------'
What happens with this that once the browser loads Image1 at the top left corner of the page, Image1 at the bottom right corner instantly shows up at the same time... It doesn't only happen on Firefox, but on any browser I've used so far.

So basically, my question is, what is the point of this MOD? I don't mean to sound offending (or discouraging) in any way, I was just wondering why one would need this MOD if most major browsers already download images once and load everywhere on page... no extra bandwidth is wasted.

Good work nonetheless =]
Last edited by ultima528 on Tue Mar 08, 2005 1:55 am, edited 1 time in total.
User avatar
Flaming_cows
Registered User
Posts: 761
Joined: Sat Jul 05, 2003 1:43 am
Contact:

Post by Flaming_cows »

Why not strip out the image tags right when the quoter posts?

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
#
         // Use trim to get rid of spaces placed there by MS-SQL 2000
         $quote_username = ( trim($post_info['post_username']) != '' ) ? $post_info['post_username'] : $post_info['username'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
         $message = preg_replace('/(\[img\]((.|\n)*)\[\/img\])/si',"[Quoted Image]",$message);
Cyberpenguin
Registered User
Posts: 14
Joined: Fri Nov 26, 2004 8:28 am

Post by Cyberpenguin »

Flaming_cows wrote: Why not strip out the image tags right when the quoter posts?

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
#
         // Use trim to get rid of spaces placed there by MS-SQL 2000
         $quote_username = ( trim($post_info['post_username']) != '' ) ? $post_info['post_username'] : $post_info['username'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
         $message = preg_replace('/(\[img\]((.|\n)*)\[\/img\])/si',"[Quoted Image]",$message);


because it wont fix already quoted images in your forum, only prevent future ones.
User avatar
Flaming_cows
Registered User
Posts: 761
Joined: Sat Jul 05, 2003 1:43 am
Contact:

Post by Flaming_cows »

How often do people bring up old threads with quoted images?
Cyberpenguin
Registered User
Posts: 14
Joined: Fri Nov 26, 2004 8:28 am

Post by Cyberpenguin »

Flaming_cows wrote: How often do people bring up old threads with quoted images?


I did it all the time, which is why i wrote the new one.
Post Reply

Return to “[2.0.x] MODs in Development”