Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-06-15 09:28:39

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

<img> sometimes in a <p> tag ... sometimes not ... !?

On this site sometimes <img> tags are enclosed with <p> tags … and on other pages the <img> is a standalone tag … !? This gives margin problems (whitespace). Textpattern has version 4.7.3

A known issue?

Last edited by RedFox (2019-06-15 09:29:22)

Offline

#2 2019-06-15 10:40:25

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

A wild guess: was the site updated from an earlier version of textpattern?

Depending on how you are inserting your images, previous versions wrapped an html tag starting at the beginning of the line in a <p> tag. To avoid that you had to start the line with a space or with notextile..

More recent versions of textpattern (I forget exactly when but 4.7+) no longer wrap tags in a p.

That could be an explanation if you are seeing the <p><img … ></p> in older articles but not in more recent ones since the upgrade. That’s pure conjecture but maybe it mirrors what you’re seeing…

Because the site uses the pre-rendered html from the textile, the ‘older’ articles will show how they were. Once you re-save them, the behaviour will change.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2019-06-15 10:42:48

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

BTW: If you’re going to rejig the articles anyway, you might like to use this image with caption shortcode to get proper figure … figcaption markup.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2019-06-15 11:26:05

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,078
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

As Jacob alludes, there were some changes in TXP 4.7.3 / Textile related to wrapping things in <p /> tags or not.

All depends if your images are inserted on their own line in the source preceded by a space or not


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#5 2019-06-15 14:00:55

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

jakob wrote #318480:

More recent versions of textpattern (I forget exactly when but 4.7+) no longer wrap tags in a p.

Phrasing tags should still be wrapped in <p></p>. Weirdly, <img /> seems to fail.

Offline

#6 2019-06-15 15:48:03

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

Oké … thanks all. Is there a way to (re)save all (live) articles at once? Via the database perhaps?

@jakob … I will make a proposal to my client … :)

[edit]
After resaving a number of articles some <p> tags are gone but, unfortunately, some stay where they are … :(

Last edited by RedFox (2019-06-15 19:00:35)

Offline

#7 2019-06-16 16:59:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

RedFox wrote #318486:

Is there a way to (re)save all (live) articles at once?

There’s sed_textile_upgrade. That makes a copy of the textpattern table in the DB and then batch textiles all body and excerpt fields in the DB.

This is an updated version for Textpattern v4.7 (also on github):

# sed_textile_upgrade v0.2.1
# Facilitates textile upgrades to your Textpattern v4.7+ article body and excerpt texts
# Netcarver + jcr
# https://github.com/jools-r/sed_textile_upgrade

# ......................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# ......................................................................

H4sIAAAAAAAAE8VY61IbRxb+LT1FZ6AiocBIwuDLIBEMlhPKBLuwdr1bcQqPZlqaNqPpyXSP
hMpFVd4hv/b18iT7ne4ZXYwwOHsJZYzUl3M/5zt9fK+9631S3hPPmfBMCZk4B8rb95yWu+u2
6fNjz/FzHcmMvrSxc8514Gc4zb5jHwO73CoPXeaZoJU9XIu0TpXXbI6EjvKBG8hx86OUsdrJ
moqHl5pfaxHzyzwdZX7IDZ2254RcBZlIdSHKU3B86QciFtrXXLHiFituYUGymcwz1sdG6mvN
s4RN9twn3zE/0yLA0YEMZ8xPQsavA56l2tBQhZ4yCzl0EF6bpPYcPUs5fX1kt4exP1L0fddu
J/7YSvrMc+5QAqciHqfm1NM9nKt0ovbhmsOd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//T
1BacHjSsrVZXhrP4ap8+jT81jW385VPYL3iOZD0ioiuOgQUa58de4781WL03dMAw2nXZfJBK
EdiwI9PG/2JUOiffavypkWhxv+0+ajx09Oksjywd7z8bgFLzrLxHnjMO982nXc8Jn+3z1nCf
D4dPn7Uft58McXCwGzze3R8ErWd7A+fg5t900+DitR0AAA==

TXP Builders – finely-crafted code, design and txp

Offline

#8 2019-08-27 08:17:36

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

jakob wrote #318494:

There’s sed_textile_upgrade. That makes a copy of the textpattern table in the DB and then batch textiles all body and excerpt fields in the DB.

This is an updated version for Textpattern v4.7 (also on github):

# sed_textile_upgrade v0.2...

This plugin doesn’t seem to work for me, Jacob. Could it be because I have an en_ prefix before my textpattern table (en_textpattern)?

If so, should I add this prefix to the name of the textpattern table in the plugin code?

Last edited by Kjeld (2019-08-27 08:33:15)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#9 2019-08-27 10:13:59

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

Kjeld wrote #319159:

This plugin doesn’t seem to work for me, Jacob. Could it be because I have an en_ prefix before my textpattern table (en_textpattern)?

If so, should I add this prefix to the name of the textpattern table in the plugin code?

Well spotted. That was obviously missing in the original plugin, too.

EDIT: The plugin is now updated with these changes.

Assuming your prefix is already specified in your config.php, you should just need to to amend the two following lines:

Line 60

$sql = "CREATE TABLE ".safe_pfx('textpattern_pre_textile_upgrade')." LIKE ".safe_pfx('textpattern').";";

Line 63

$sql = "INSERT INTO ".safe_pfx('textpattern_pre_textile_upgrade')." SELECT * FROM ".safe_pfx('textpattern').";";

The principle above is analog to the inner workings of Textpattern’s own functions, e.g. here .

That should insert your prefix from the config when creating and populating the backup database. The other database operations already use Textpattern’s built-in safe_... functions that automatically use the prefix.

Edit: added an issue on GitHub to update the plugin.


TXP Builders – finely-crafted code, design and txp

Offline

#10 2019-08-27 10:54:57

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

jakob wrote #319160:

Assuming your prefix is already specified in your config.php, you should just need to amend the two following lines …

Thanks, Jakob.

It worked!

Last edited by Kjeld (2019-08-27 11:10:46)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#11 2019-08-27 12:20:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

Kjeld wrote #319161:

It worked!

Thanks for confirming that. I’ve updated the plugin on GitHub and in the post above.


TXP Builders – finely-crafted code, design and txp

Offline

#12 2019-08-27 12:23:09

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: <img> sometimes in a <p> tag ... sometimes not ... !?

Just a final note on this plugin. Instead of transforming a double line between paragraphs into </p><p>, it transformed it into <br /><br />).

This may not be what some users may hope for…


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

Board footer

Powered by FluxBB