[MODDB] Convert quoted images to url

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!
Ideas Centre
Locked
User avatar
Ger
Recognised Extension Developer
Posts: 1887
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

[MODDB] Convert quoted images to url

Post by Ger » Wed Oct 08, 2008 12:03 pm

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, like [ Image ]

Modification Version:: 1.0.1.RC

Modification Download: Download as MODX
Last edited by Ger on Fri Nov 07, 2008 12:54 pm, 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:
-Available for custom work-

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: [ALPHA] Convert quoted images to url

Post by ChriZathens » Wed Oct 08, 2008 1:14 pm

Nice... :D
Can you make it so that "User posted image" is not hardcoded?
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

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

Re: [ALPHA] Convert quoted images to url

Post by Ger » Wed Oct 08, 2008 1:35 pm

Yes, I can. :mrgreen:
Check out the edited code. It now also fixes thumbnailed images from Imageshack and services like that.
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:
-Available for custom work-

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: [ALPHA] Convert quoted images to url

Post by ChriZathens » Wed Oct 08, 2008 1:43 pm

Lol thanks... I had already done it, I just used

Code: Select all

$user->lang['IMAGE']
to avoid adding another lang string in the lang files, but you were faster than me in posting the addition :lol: :lol:

Anyways, congrats man... really usefull mod ;)
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

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

Re: [RC] Convert quoted images to url

Post by Ger » Wed Oct 08, 2008 3:18 pm

That's indeed easyer, so I changed that. Together with some other small changes I created a MODx file with it and submitted it to the MOD database. :)
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:
-Available for custom work-

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: [RC] Convert quoted images to url

Post by ChriZathens » Wed Oct 08, 2008 3:56 pm

If you mean that you changed it to $user->lang['IMAGE'] then I must inform you that the modx download includes instructions for adding a new lang string ('QUOTED_IMAGE').
If you mean something else then I apologize.. :oops:
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

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

Re: [RC] Convert quoted images to url

Post by Ger » Wed Oct 08, 2008 4:00 pm

You were right, but you're not anymore. ;)

Thanks.
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:
-Available for custom work-

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

Re: [RC] Convert quoted images to url

Post by Ger » Wed Oct 22, 2008 12:29 pm

On phpBB.nl some guys pointed out they had some annoying errors with smilies when using this MOD. Although not everyone has this problem (for instance: I didn't), I changed the MOD a bit so the error doesn't occur at all and it still does the job even when you didn't have errors in the first place. Also it fixes a small bug when using multiple quotes in a message and having an image between them.

To update, you should undo the changes you made earlier and do:

OPEN
/includes/message_parser.php

FIND
(around line 36)

Code: Select all

   /**
   * Parse BBCode
   */
   function parse_bbcode()
   {
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){
			$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);
			$this->message = str_replace($qmatchin, $qres, $this->message);
		}
		//End MOD Convert quoted images to url
Save, close, upload file.

I'll change this in de MOD file ASAP.
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:
-Available for custom work-

Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [RC] Convert quoted images to url

Post by Artack » Thu Oct 30, 2008 8:07 am

during posting can see

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
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3748: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2976)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3750: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2976)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3751: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2976)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3752: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2976)
after posting no errors

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

Re: [RC] Convert quoted images to url

Post by Ger » Thu Oct 30, 2008 7:56 pm

Are you sure you follewed the instruction correctly? Line 30-50 should be:

Code: Select all

class bbcode_firstpass extends bbcode
{
	var $message = '';
	var $warn_msg = array();
	var $parsed_items = array();

	/**
	* Parse BBCode
	*/
	function parse_bbcode()
	{
		//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\]#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);
			$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:
-Available for custom work-

Artack
Registered User
Posts: 312
Joined: Thu Feb 07, 2008 11:26 pm

Re: [RC] Convert quoted images to url

Post by Artack » Fri Oct 31, 2008 12:07 am

yes, I'm sure

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

Re: [RC] Convert quoted images to url

Post by Ger » Fri Oct 31, 2008 8:08 am

Hmm... strange. The error states that $user isn't initiated. That should already be done in includes/session.php (check sourcecode documentation). Even if you're posting as a guest it should work correct: the default language of your board should be used. So I'm guessing the bug is somewhere else, not really in this mod.

Anyway: there is a way to by-pass this, using the hardcoded technique. In that case you should replace

Code: Select all

'[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]'
with

Code: Select all

'[ [url=\1]Image[/url] ]'
or whatever your default language word for Image is. That should be done 3 times.

That's a bypass though, not really solving the bug.
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:
-Available for custom work-

User avatar
ac_roma
Registered User
Posts: 307
Joined: Thu Mar 08, 2007 2:48 pm
Location: egypt,alexandria
Contact:

Re: [RC] Convert quoted images to url

Post by ac_roma » Fri Oct 31, 2008 9:08 am

nice idea and nice mod thanks ger

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

Re: [RC] Convert quoted images to url

Post by Ger » Fri Nov 07, 2008 12:54 pm

This MOD is now validated, check http://www.phpbb.com/community/viewtopi ... &t=1282765

Topic is therefore closed.
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:
-Available for custom work-

Locked

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