Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-04-22 09:19:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,728
Website GitHub

Article image URLs: how to use forms and breaks?

The new feature that allows direct https:// URLs in the article image field is not quite working, imo.

STR (not on demo site, as it doesn’t allow image URLs for some reason) on a stock 4.9.0-dev installation:

  1. Create a new article.
  2. Add two comma-separated image URLs to the Article Image field, e.g.:
    1. https://cdn.pixabay.com/photo/2014/06/03/19/38/board-361516_1280.jpg
    2. https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Test.svg/1240px-Test.svg.png
  3. Save.
  4. View article.

ER: Image URLs show up one after the other.
AR: Image URLs show up one after the other, with br between them.

Further, it is not possible to pass such images through a form. In the default Form, the stock install uses <txp:images form="images" /> but that “images” form is ignored if the article image contains a URL-style link. Confusing.

This means it’s not possible to add overlays or other text or any surrounding markup unless it’s done in the calling environment — in this case, by surrounding the call to <txp:images> in Form default with markup. And even then, it’s only markup that can be output around the entire set of images, not per image.

To even attempt to do this effectively and retain the ability to pass regular images to the form as normal, it requires a further test to check (via <txp:if_custom_field name="article_image">...) to see if the image contains a URL-style link, rather than one from Txp’s internal store, and then do something different (such as set break="" or call <txp:output_form> and manually split and go through each image inside that Form).

So, two things:

  • We need to somehow fix the rogue ‘br’ break from showing if more than one URL is supplied; and, possibly related:
  • Is there any way we can still pass external images through a form or (more easily) detect which type of image has been supplied (URL, versus Txp ID versus Txp internal reference to an image) so that processing can be differentiated in the various cases?

Last edited by Bloke (2025-04-22 09:24:44)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2025-04-22 13:09:40

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,345
GitHub

Re: Article image URLs: how to use forms and breaks?

Bloke wrote #339588:

STR (not on demo site, as it doesn’t allow image URLs for some reason) on a stock 4.9.0-dev installation:

Likely a CSP limitation, leave it with me and I’ll change it.

Edit: demo sites now allow Pixabay CDN images.

Last edited by gaekwad (2025-04-22 13:18:46)

Offline

#3 2025-04-22 15:48:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,728
Website GitHub

Re: Article image URLs: how to use forms and breaks?

gaekwad wrote #339589:

Likely a CSP limitation… demo sites now allow Pixabay CDN images.

Awesome, thank you so much. Didn’t think to check the console.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 Yesterday 09:08:16

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

Re: Article image URLs: how to use forms and breaks?

These external images are not supposed to be imported into txp db, so have no height/width/etc data available. How would eventual <txp:image_info /> act in forms in this case?

Offline

#5 Yesterday 09:23:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,728
Website GitHub

Re: Article image URLs: how to use forms and breaks?

etc wrote #339602:

These external images are not supposed to be imported into txp db, so have no height/width/etc data available. How would eventual <txp:image_info /> act in forms in this case?

Yeah, I get that. But we should still be able to operate on them individually because someone (i.e. me!) might want to add custom field data on top of each one in a transparent CSS, floating panel. It also doesn’t allow us to wrap individual images in <figure> tags or <div> tags, for example, with additional markup beyond wraptag and class / break etc.

So we need to be able to iterate over them still, imo, even if image context is mostly empty (aside from <txp:image_url>).

Last edited by Bloke (Yesterday 09:26:18)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 Yesterday 09:30:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,728
Website GitHub

Re: Article image URLs: how to use forms and breaks?

gaekwad wrote #339589:

Edit: demo sites now allow Pixabay CDN images.

Hmm, I’m still seeing:

Content-Security-Policy: The page’s settings blocked the loading of a resource (img-src) at https://cdn.pixabay.com/photo/2014/06/03/19/38/board-361516_1280.jpg because it violates the following directive: “img-src data: ‘self’”

on dev-demo.textpattern.co/dev/index.php


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB