Some images are shown as [img]<image_url>[/img] instead of displaying the image

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by JoshyPHP »

I didn't realize that neither images nor links were parsed in those old posts. You'll need to modify the root element to replace <t> with <r> too:

Code: Select all

UPDATE phpbb_posts SET post_text = REPLACE(REPLACE(REPLACE(REPLACE(post_text, '[/img]', '<e>[/img]</e>'), '<e><e>[/img]</e>', '<e>[/img]'), '<t>', '<r>'), '</t>', '</r>') WHERE post_text LIKE '%[/img]%'
Alternatively, you could try writing a small extension that unconditionally enables links and images before parsing. I think there's an event for it somewhere in the generate_text_for_storage() function.
I wrote the library that handles markup in phpBB 3.2+.
User avatar
P_I
Community Team Member
Community Team Member
Posts: 2365
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by P_I »

RS246.com wrote: Tue Apr 25, 2017 6:06 pm I Like your thinking Joshy.

I tried this (Added <e>[/img]</e>):
INSERT INTO `phpbb_posts` VALUES (45309,45307,1,6,0,'62.253.96.44',1078902662,0,1,1,1,1,'','Re: My car looks fast, and its not even moving !','<t>Nice <s>[img]</s>https://cdn.rs246.com/images/graemlins/cool.gif<e>[/img]</e></t>','',0,'CA==','210wozgu',1,0,'',6,0,0,'',1,0,'',0);
A heads up. There is a BBCode for code listings that doesn't show in the posting mode, it is [code], so the above could be posted as

Code: Select all

INSERT INTO `phpbb_posts` VALUES (45309,45307,1,6,0,'62.253.96.44',1078902662,0,1,1,1,1,'','Re: My car looks fast, and its not even moving !','<t>Nice <s>[img]</s>https://cdn.rs246.com/images/graemlins/cool.gif<e>[/img]</e></t>','',0,'CA==','210wozgu',1,0,'',6,0,0,'',1,0,'',0);
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
RS246.com
Registered User
Posts: 11
Joined: Mon Apr 24, 2017 4:00 pm

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by RS246.com »

Thanks P_I I did use the code bbcode before but liked the way the c bbcode was easier to read on screen (no scrolling). Maybe the code bbcode should wrap text or have a wrap option, anyway that's not the topic in play here 8-)

JoshyPHP, I did more testing....

This time I copied prod to test and ran the reparser. My expectation was that posts that contained '<t>Nice [img]/images/graemlins/cool.gif[/img]</t>' would have the <t> </t> tags changed to <r> </r> tags, but instead they appear to be unchanged....

I'm afraid that my coding skills are not good enough to take on writing an extension, so that option isn't for me :oops:

So, I'm wondering under which conditions does a post get reparsed and why wouldn't '<t>Nice [img]/images/graemlins/cool.gif[/img]</t>' get reparsed? Is there anywhere that can enlighten me on the logic in the reparser please?
RS246.com
Registered User
Posts: 11
Joined: Mon Apr 24, 2017 4:00 pm

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by RS246.com »

I seem to have found a solution that I need to test for any side effects.... :)

If I change the image links to smilies, i.e. '<t>Nice [img]/images/graemlins/cool.gif[/img]</t>' to '<t>Nice 8-)</t>' and then run the reparser I get the smilie 8-) . Reparsed post_text is <r>Nice <E>8)</E> </r>

Taking me ages to test all these changes before I'm confident enough to execute in prod. Luckily, I'm a script kiddie (albeit an old one) and I have lots of scripts to automate the loading and mods.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by JoshyPHP »

RS246.com wrote: Wed Apr 26, 2017 6:02 pm This time I copied prod to test and ran the reparser. My expectation was that posts that contained '<t>Nice [img]/images/graemlins/cool.gif[/img]</t>' would have the <t> </t> tags changed to <r> </r> tags, but instead they appear to be unchanged....
If images weren't displayed in the original post, they won't be displayed in the reparsed post. The reason is that some BBCodes are disabled (by permissions or other things) and whether or not they're disabled happens when the post is submitted, then this information is discarded. It's not saved with the post so when reparsing it's inferred based on the presence of a parsed image.

Have you tried the query from this previous post? It should be enough to re-enabled images. It's case-sensisitive though.
I wrote the library that handles markup in phpBB 3.2+.
RS246.com
Registered User
Posts: 11
Joined: Mon Apr 24, 2017 4:00 pm

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by RS246.com »

JoshyPHP wrote: Thu Apr 27, 2017 9:49 amHave you tried the query from this previous post? It should be enough to re-enabled images. It's case-sensisitive though.
It's been a busy day and a quick test seems to have returned me back to where I started. I will do a more detailed update when I get time. I wanted to respond but I also want to provide useful feedback!!
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Some images are shown as [img]<image_url>[/img] instead of displaying the image

Post by JoshyPHP »

I realize I forgot to mention in my second post that you'll need to run this query before reparsing the posts.
I wrote the library that handles markup in phpBB 3.2+.
Post Reply

Return to “[3.2.x] Support Forum”