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.
spoda-b.com
Registered User
Posts: 52
Joined: Wed Dec 31, 2008 8:09 pm

Re: Convert quoted images to url

Post by spoda-b.com »

this also does not work if i have auto redirect mod installed.
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

I don't have any experience with the automod, so I don't have a clue what could be wrong... Can you please post line 30-70 of includes/message_parser.php for me? Perhaps then I can see what's wrong.

(I have the redirect-mod installed myself, it shouldn't have anything to do with it)
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-
spoda-b.com
Registered User
Posts: 52
Joined: Wed Dec 31, 2008 8:09 pm

Re: Convert quoted images to url

Post by spoda-b.com »

Ger wrote:I don't have any experience with the automod, so I don't have a clue what could be wrong... Can you please post line 30-70 of includes/message_parser.php for me? Perhaps then I can see what's wrong.

(I have the redirect-mod installed myself, it shouldn't have anything to do with it)
Yep, but now they're both working. I think it mightve been another mod I had installed.

Code: Select all

{
	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

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

		global $user;

		$this->bbcode_bitfield = '';
		$bitfield = new bitfield();

		foreach ($this->bbcodes as $bbcode_name => $bbcode_data)
		{
			if (isset($bbcode_data['disabled']) && $bbcode_data['disabled'])
			{
				foreach ($bbcode_data['regexp'] as $regexp => $replacement)
				{
					if (preg_match($regexp, $this->message))
					{
						$this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']');
						continue;
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

So it's working now?
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
paciuli
Registered User
Posts: 64
Joined: Thu Dec 06, 2007 10:36 pm

Re: Convert quoted images to url

Post by paciuli »

Ger wrote:With the $2 backreference you get the second sample pattern (within ( and ) ).
Thank you very much, it works and I've learnt something new :)
Biliardoweb - Italian billiard community - http://www.biliardoweb.com
spoda-b.com
Registered User
Posts: 52
Joined: Wed Dec 31, 2008 8:09 pm

Re: Convert quoted images to url

Post by spoda-b.com »

Ger wrote:So it's working now?
yep.
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

paciuli wrote:Thank you very much, it works and I've learnt something new :)
Glad I could help. :)
spoda-b.com wrote:
Ger wrote:So it's working now?
yep.
Great. :)
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
wang5555
Translator
Posts: 625
Joined: Wed Oct 27, 2004 2:57 pm
Location: Taiwan

Re: Convert quoted images to url

Post by wang5555 »

Ger wrote: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]', '[img]', $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)
Source: http://www.phpbb.com/community/viewtopi ... 5#p7627405
Suggest this article amend a small mistake:

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

Code: Select all

$this->message = str_replace($$crepl, $qcode[1], $this->message);
#
#-----[ REPLACE WITH ]-----
#

Code: Select all

$this->message = str_replace($crepl, $qcode[1], $this->message);
It is more blessed to give than to reveive, good luck! ^_^
Welcome to my forum
https://wang5555.dnsfor.me/phpBB3/
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

You're right. I noticed this error before, but I didn't thought of that message. I changed it now.

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:

-Don't PM me for support-
User avatar
DoYouSpeakWak
Registered User
Posts: 2311
Joined: Fri Jul 25, 2008 1:32 pm
Location: Island of Wak-Wak

Re: Convert quoted YouTube to url

Post by DoYouSpeakWak »

DragonMaster1 wrote:
RupertGee wrote:This is a great mod; images in quotes are so annoying.

My board also lets users post YouTube video. That means the video gets quoted too! Argh! So I modded this mod to take care of YouTube too, converting the embedded video player to a text link when quoted. It's my first mod-of-mod.... :)

Look for:

Code: Select all

$qres = preg_replace('#\[img\](.*)\[/img\]#iU', '[ [url=\1]'. $user->lang['IMAGE'] .'[/url] ]', $qmatchin);
Add after:

Code: Select all

$replacement = preg_replace('#\[youtube\]\n*(.*)\n*\[/youtube\]#iU', '[url=$1]Writer posted a YouTube video[/url]', $replacement); // RupertGee Addition
My board supports English only and so I hardcorded the text link; you'll want to change that to language specific text for your multi-lingual board.
Does not work for me
Confirmed this doesnt work. Tried it wit alot of diffrent bbcodes, incl. the standard youtube. No go with either of them.

To Ger
This is really helpfull, but mostly on plain boards with no extra bbcodes added. Boards today have more and more bbcodes for all kind of stuff. If you somehow could make a guide how to remove or replace custom bbcodes in qoutes it would really enhance the usage of this mod and im pretty sure most people after they insalll this mod will think."How can i add more bbcodes to this"

I hope for somone to post the perfect solution for this.
Whatever you share comes back. Support the phpBB Communities
Offering paid services. 15+ years of experience with phpBB3 and server management.
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted YouTube to url

Post by Ger »

DoYouSpeakWak wrote:To Ger
This is really helpfull, but mostly on plain boards with no extra bbcodes added. Boards today have more and more bbcodes for all kind of stuff. If you somehow could make a guide how to remove or replace custom bbcodes in qoutes it would really enhance the usage of this mod and im pretty sure most people after they insalll this mod will think."How can i add more bbcodes to this"

I hope for somone to post the perfect solution for this.
Well, that's easyer said then done. Custom BBcodes have the annoying property to be custom. ;) Therefore, I can't predict what the BBcode contains and what to replace. Removing is very easy, but in general I don't expect that you want to remove parts of the post content. But here's a general guide to remove a BBcode:


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 removing BBcode. Replace all the [**bbcode**] and [/**bbcode**] with your bbcode for it to work.
      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('[**bbcode**]', '[**bbcode**]', $qcode[1]);
         $replacement = str_replace($qcode[1], $crepl, $qmatchin);
         $replacement = preg_replace('#\[**bbcode**\]\n*(.*)\n*\[/**bbcode**\]#iU', '[ Removed custom BBcode ]', $replacement);
         $this->message = str_replace($qmatchin, $replacement, $this->message);
         $this->message = str_replace($crepl, $qcode[1], $this->message);
      }
      //End MOD removing BBcode
Bear in mind that above hasn't been tested at all and isn't really monkey-proof either.
Last edited by Ger on Thu Jan 22, 2009 7:09 am, edited 1 time 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
wang5555
Translator
Posts: 625
Joined: Wed Oct 27, 2004 2:57 pm
Location: Taiwan

Re: Convert quoted YouTube to url

Post by wang5555 »

Remind again:
If user forum enable DEBUG, the code will appear PHP DEBUG error.
It is recommended to use "$crepl" to replace "$$crepl".
It is more blessed to give than to reveive, good luck! ^_^
Welcome to my forum
https://wang5555.dnsfor.me/phpBB3/
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

You're right. :oops:
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-
JeRicHoOL
Registered User
Posts: 449
Joined: Sun Jun 01, 2008 4:02 pm

Re: Convert quoted images to url

Post by JeRicHoOL »

It works great. Thanks for this mod.

Can you tell me how every link is displayed on a seperte line?

Right now it's like:
TEXT LINK TEXT
http://i107.photobucket.com/albums/m287 ... 070118.gif

I want it:
TEXT
LINK
TEXT
User avatar
Ger
Registered User
Posts: 2117
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100

Re: Convert quoted images to url

Post by Ger »

Probably the image in the original post isn't on a seperate line. You could try and force this by replacing this line:

Code: Select all

$this->message = str_replace($qmatchin, $replacement, $this->message);
with

Code: Select all

$this->message = str_replace($qmatchin, '<p>'.$replacement.'</p>', $this->message);
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-

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