Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-01-19 02:49:24

BryanA.
Member
From: Maryland, USA
Registered: 2007-08-12
Posts: 96

RSS image via Custom field?

The Article Image field is great and I’ve gotten loads of use out of it but I have matching images for each post that goes to the feed. I haven’t figured out if there’s an easy way to ‘tell’ the feed to use image 123

Is it possible to implement code for the RSS feed that utilizes a full-on URL or Image ID in the Custom field chosen?


The WIPsnakebite.cafe
A place for conversations like #techxiety the podcast. Textpattern is my Valentine’s date.

Offline

#2 2019-01-19 09:36:26

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,164
Website

Re: RSS image via Custom field?

In txp v4.7 you could create your own rss feed using forms. There is one line below (guid isPermaLink) which I’m not sure what it does, or how to parse it. Maybe it is not needed?

<txp:header name="Cache-Control" value="no-cache, no-store, must-revalidate" />
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<generator>https://textpattern.com/</generator>
<link><txp:site_url /></link>
<atom:link href="<txp:site_url />?f=rss" rel="self" type="application/rss+xml" />
<txp:article_custom sort="LastMod" limit="1" form="">
<pubDate><txp:modified format="%a, %m %b %Y %X GMT" /></pubDate>
</txp:article_custom>
<txp:article_custom form="">
<item>
<title><txp:title /></title>
<description><![CDATA[<txp:article_image /> <txp:excerpt />]]></description>
<link><txp:permlink /></link>
<pubDate><txp:posted format="%a, %m %b %Y %X GMT" /></pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</item>
</txp:article_custom>
</channel>
</rss>

> Edited to add: The above is based on txp’s rss feed structure, do check out the rss 2 samples as they should be of help.

Last edited by colak (2019-01-19 20:20:54)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#3 2019-01-19 16:52:53

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,157
Website

Re: RSS image via Custom field?

colak wrote #316178:

In txp v4.7 you could create your own rss feed using forms. There is one line below (guid isPermaLink) which I’m not sure what it does, or how to parse it. Maybe it is not needed?

GUID (or UUID) is an acronym for ‘Globally Unique Identifier’ (or ‘Universally Unique Identifier’). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else. – Online GUID Generator

If you are using the guid element as a permanent link, make sure the value is a full URL, that could be followed directly in a browser. If you are using the guid element simply as a unique identifier (and not a link to the item), then the value can be whatever you want, but you must include the attribute isPermaLink=“false” in the guid tag. – guid must be a full URL, unless isPermaLink attribute is false

So you could replace it with

<guid><txp:permlink></guid>

Offline

#4 2019-01-19 20:21:42

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,164
Website

Re: RSS image via Custom field?

michaelkpate wrote #316180:

So you could replace it with

<guid><txp:permlink></guid>...

Nice one Michael!! Corrected above.

ps. I think that the form should be saved in xml format


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#5 2019-01-20 17:56:12

etc
Developer
Registered: 2010-11-11
Posts: 3,131
Website

Re: RSS image via Custom field?

There are some RSS-specific headers that are difficult to construct via txp tags. You actually can inject additional markup into the standard txp RSS feed. Install this tiny plugin:

# Name: etc_rss v0.1 
# Type: Public plugin
# 
# Author: 
# URL: 
# Recommended load order: 5

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

YToxMTp7czo0OiJuYW1lIjtzOjc6ImV0Y19yc3MiO3M6NjoiYXV0aG9yIjtzOjA6IiI7czox
MDoiYXV0aG9yX3VyaSI7czowOiIiO3M6NzoidmVyc2lvbiI7czozOiIwLjEiO3M6MTE6ImRl
c2NyaXB0aW9uIjtzOjA6IiI7czo0OiJjb2RlIjtzOjYxMDoicmVnaXN0ZXJfY2FsbGJhY2so
J2V0Y19yc3NfaW5zdGFsbCcsJ3BsdWdpbl9saWZlY3ljbGUuZXRjX3JzcycpOw0KcmVnaXN0
ZXJfY2FsbGJhY2soJ2V0Y19yc3MnLCAncnNzX2hlYWQnKTsNCnJlZ2lzdGVyX2NhbGxiYWNr
KCdldGNfcnNzJywgJ3Jzc19lbnRyeScpOw0KLy9yZWdpc3Rlcl9jYWxsYmFjaygnZXRjX3Jz
cycsICdmZWVkX2ZpbHRlcicpOw0KDQpmdW5jdGlvbiBldGNfcnNzICgkZXZlbnQsICRzdGVw
ID0gbnVsbCkgew0KICAgIHJldHVybiBAcGFyc2VfZm9ybSgkZXZlbnQpOw0KfQ0KDQpmdW5j
dGlvbiBldGNfcnNzX2luc3RhbGwoJGV2ZW50LCAkc3RlcCkNCnsNCiAgICBpZiAoJHN0ZXAg
PT0gJ2VuYWJsZWQnKSB7DQogICAgICAgIC8vIEZlZWRzIG5hbWVzcGFjZXMNCiAgICAgICAg
aWYgKGdldF9wcmVmKCdmZWVkc19uYW1lc3BhY2VzJywgZmFsc2UpID09PSBmYWxzZSkNCiAg
ICAgICAgICAgIHNldF9wcmVmKCdmZWVkc19uYW1lc3BhY2VzJywgJ2l0dW5lcz0iaHR0cDov
L3d3dy5pdHVuZXMuY29tL2R0ZHMvcG9kY2FzdC0xLjAuZHRkIicsICdhZHZhbmNlZF9vcHRp
b25zJywgUFJFRl9DT1JFLCAnbG9uZ3RleHRfaW5wdXQnLCA1MDApOw0KICAgIH0NCn0NCiI7
czo0OiJ0eXBlIjtzOjE6IjAiO3M6NToib3JkZXIiO3M6MToiNSI7czo1OiJmbGFncyI7czox
OiIyIjtzOjQ6ImhlbHAiO2I6MDtzOjM6Im1kNSI7czozMjoiMTllYzY5YzRkOTJmMTFhN2Mz
ZWJjZTE0NzVlZDgzNGYiO30=

and create a rss_entry Form (misc type) like

<txp:if_custom_field name="rss_image">
    <enclosure url="<txp:custom_field name="rss_image" />" length="0" type="image/jpeg" />
</txp:if_custom_field>

Change it if needed for using image id instead of full URL. Now every article should have its rss_image in RSS feed.

You can also inject what you wish (author, etc) to the head part of the RSS feed via rss_head form. Moreover, you can register additional namespaces via Advanced options feeds_namespaces preference.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#6 2019-01-23 15:34:25

BryanA.
Member
From: Maryland, USA
Registered: 2007-08-12
Posts: 96

Re: RSS image via Custom field?

This is delightful, all of it. Thank each of you for your knowledge. I was under the impression that some future iteration was going to include an easy option in the Admin area turning images on or off for feeds. Did I imagine this or perhaps it was a plugin conversation?…

In any case, these answers combined should supply everything! I’ll test it out today I think. :)


The WIPsnakebite.cafe
A place for conversations like #techxiety the podcast. Textpattern is my Valentine’s date.

Offline

#7 2019-01-23 15:56:16

etc
Developer
Registered: 2010-11-11
Posts: 3,131
Website

Re: RSS image via Custom field?

BryanA. wrote #316244:

I was under the impression that some future iteration was going to include an easy option in the Admin area turning images on or off for feeds.

This could be done in core for Article image, but pulling it from some custom field looks more like plugins territory. Good luck for testing, don’t hesitate to feed us back.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#8 2019-02-02 15:09:36

BryanA.
Member
From: Maryland, USA
Registered: 2007-08-12
Posts: 96

Re: RSS image via Custom field?

I got right on this pushing different methods and what came through in the end was a mix of etc’s three lines of code – wow! and greatly helping along the file name.

The three lines output correctly but getting image 46’s proper URL, for example, was weirdly difficult. So I just plugged it in with “46” or whatever image ID, as a variable. Then the jpg extension didn’t fire automatically so I had to be explicit with that too but left ‘type’ entact.

So my enclosure url is a bit clumsy, but looks like this:
<code><enclosure url=“https://snakebite.cafe/images/<txp:custom_field name=“article_thumb” />.jpg” length=“0” type=“image/jpeg” /></code>

It’s probably nothing, but I changed rss_image to article_thumb in every occurrence. Online RSS readers pick up the images when that field is used. Thanks to iTunes, images in question are a massive 1440×1440 pixels.

___
About the Feed Form answer, I wish I could be more help but the same online RSS readers that accepted the etc change choked pretty badly on the description area of that answer. A human reading of that xml shows that the output stops reporting the RSS items I expected to see. I love Textpattern control, so I had tried that first!


The WIPsnakebite.cafe
A place for conversations like #techxiety the podcast. Textpattern is my Valentine’s date.

Offline

#9 2019-02-02 15:40:01

etc
Developer
Registered: 2010-11-11
Posts: 3,131
Website

Re: RSS image via Custom field?

I have updated the plugin to enable RSS head and namespaces customization. Now I leave it with you validating (ever-changing) iTunes podcast requirements.

Here is an example of a valid iTunes podcast.


etc_[ query | search | pagination | date | tree | cache ]

Offline

Board footer

Powered by FluxBB