Convert quoted images to url

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
Extensions Robot
Extensions Robot
Extensions Robot
Posts: 28165
Joined: Sat Aug 16, 2003 7:36 am

Convert quoted images to url

Post by Extensions Robot »

Modification name: Convert quoted images to url
Author: Ger
Modification description: Images in quotes are both useless and pretty annoying, since the images are already posted before and quoting them takes op a lot of space. This MOD fixes that: images that are quoted are being converted to the corresponding url.
Modification version: 2.0.0
Tested on phpBB version: 3.0.10

Download file: convert_quoted_images_to_url.zip
File size: 33.36 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extensions Team may not be able to provide support.

-->Modification support<--
Last edited by Extensions Robot on Mon Mar 27, 2017 3:09 pm, edited 10 times in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26040
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Convert quoted images to url

Post by Paul »

Modification validated/released

Notes:
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

User avatar
Ger
Recognised Extension Developer
Posts: 1934
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Convert quoted images to url

Post by Ger »

Having errors? Read this...

Some users (not all, for a strange reason) encouter an error as reported below by Eragon. Also, I found a small bug when using nested quote-code-img-tags. A solution to both of this is to undo the steps of the MOD and do:

OPEN
./includes/message_parser.php

FIND

Code: Select all

	/**
	* Parse BBCode
	*/
	function parse_bbcode()
	{
		if (!$this->bbcodes)
		{
			$this->bbcode_init();
		}

		global $user;
ADD AFTER

Code: Select all

		//Start MOD Convert quoted images to url
		preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
		foreach ($qmatch[2]as $qmatchin){
			preg_match_all('#\[code\](.*?)\[/code\]#is', $qmatchin, $qcode);
			$crepl = str_replace('[img]', '&#91;img&#93;', $qcode[1]);
			$replacement = str_replace($qcode[1], $crepl, $qmatchin);
			$replacement = preg_replace('#\[url=\n*(.*(jpg|jpeg|gif|png|bmp))\n*\]\n*\[img\]\n*(.*)\n*\[/img\]\n*\[/url\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement);
			$replacement = preg_replace('#\[url=\n*(.*)\n*\]\n*\[img\]\n*(.*)\n*\[/img\]\n*\[/url\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement);
			$replacement = preg_replace('#\[img\]\n*(.*)\n*\[/img\]#iU', '[ [url=$1]'. $user->lang['IMAGE'] .'[/url] ]', $replacement);
			$this->message = str_replace($qmatchin, $replacement, $this->message);
			$this->message = str_replace($crepl, $qcode[1], $this->message);
		}
		//End MOD Convert quoted images to url 
Save, close, upload file.

When you're still encoutering some errors after this, just post a message in this topic and I'll happily support you. :)
(please do not PM me for support)
Last edited by Ger on Mon Jan 19, 2009 8:20 am, edited 7 times in total.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-

User avatar
Eragon
Registered User
Posts: 218
Joined: Tue Oct 07, 2008 1:57 pm

Re: Convert quoted images to url

Post by Eragon »

Debug mode on : posting.php error..

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 44: Undefined variable: user
[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 44: Trying to get property of non-object
[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 45: Undefined variable: user
[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 45: Trying to get property of non-object
[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 46: Undefined variable: user
[phpBB Debug] PHP Notice: in file /includes/message_parser.php on line 46: Trying to get property of non-object
line: 44-45-46

Code: Select all

$qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
$qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
$qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);

what is this ?

[ .. ]
my post

thanks

User avatar
Ger
Recognised Extension Developer
Posts: 1934
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Convert quoted images to url

Post by Ger »

I don't get that error, but maybe that's related to PHP-settings. Let's see... Can you try this:

In ./includes/message_parser.php, just under the MOD-code, you find:

Code: Select all

		if (!$this->bbcodes)
		{
			$this->bbcode_init();
		}

		global $user;
Can you move the MOD-code to just below that, and tell me the result?
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-

User avatar
WhiteWolfSix
Registered User
Posts: 258
Joined: Sun May 15, 2005 5:43 am

Re: Convert quoted images to url

Post by WhiteWolfSix »

Great MOD. thanx


Edit: Installed, works perfectly.
Last edited by WhiteWolfSix on Fri Nov 07, 2008 1:22 pm, edited 1 time in total.
Image
WhiteWolfSix (WW6)

User avatar
Eragon
Registered User
Posts: 218
Joined: Tue Oct 07, 2008 1:57 pm

Re: Convert quoted images to url

Post by Eragon »

I don't understand :? .. It is working localhost but It isn't working on my website :roll:


thanks

User avatar
Ger
Recognised Extension Developer
Posts: 1934
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Convert quoted images to url

Post by Ger »

1 running linux, 1 running windows? Could be the difference in line-breaks, very annoying at times. Try:

Code: Select all

		//Start MOD Convert quoted images to url 	
		preg_match_all('#\[quote(.*?)\](.*?)\[/quote\]#si', $this->message, $qmatch );
		foreach ($qmatch[2]as $qmatchin){
			$qres = preg_replace('#\[url=(.*(jpg|jpeg|gif|png|bmp))\]\[img\].*\[/img\]\[/url\]#iUs', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$qres = preg_replace('#\[url=.*\]\[img\](.*)\[/img\]\[/url\]#iUs', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$qres = preg_replace('#\[img\](.*)\[/img\]#iUs', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
			$this->message = str_replace($qmatchin, $qres, $this->message);
		}
		//End MOD Convert quoted images to url
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-

User avatar
Eragon
Registered User
Posts: 218
Joined: Tue Oct 07, 2008 1:57 pm

Re: Convert quoted images to url

Post by Eragon »

PHP Version 5.2.3
host : linux

I don't understand , it isn't working on my website :? .. my host is problem :evil:

thanks you Ger

User avatar
Ger
Recognised Extension Developer
Posts: 1934
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Convert quoted images to url

Post by Ger »

You sure you uploaded the file correctly, to the folder ./includes/?

Edit: I posted a possible solution in the author notes message.

Verbal
Registered User
Posts: 27
Joined: Sat Oct 11, 2008 4:43 am

Re: Convert quoted images to url

Post by Verbal »

Great mod...working perfectly on two boards I run. Thanks!

Tazmanian
Registered User
Posts: 218
Joined: Wed Jan 25, 2006 7:02 pm
Location: Belgium
Contact:

Re: Convert quoted images to url

Post by Tazmanian »

Hello Ger,

had the same error when I used the install file instructions.

However, the 'patch' you posted works for me!

Php 5.1.6

Crowndefender
Registered User
Posts: 301
Joined: Thu Jan 19, 2006 10:03 am
Location: Right here at PHPbb.com

Re: Convert quoted images to url

Post by Crowndefender »

Excellent MOD, works fine :D Thanks
ImagePHP BB Newbie.

User avatar
spicyapple
Registered User
Posts: 58
Joined: Wed Apr 23, 2008 3:53 am
Contact:

Re: Convert quoted images to url

Post by spicyapple »

Thanks! I've been looking for something like this. In addition to the mods, NoQuote in Last Post and Quote Remover, forum bloat is a thing of the past. :lol:

User avatar
spicyapple
Registered User
Posts: 58
Joined: Wed Apr 23, 2008 3:53 am
Contact:

Re: Convert quoted images to url

Post by spicyapple »

Is there a way to mask the URL address of the images, so quoted images show up as a named link, ie [IMAGE] instead of the URL?

Locked

Return to “[3.0.x] MOD Database Releases”