Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to add RSS item sub-element from page-meta-data? #6

Open
new-on-github opened this issue Apr 23, 2024 · 7 comments
Open
Assignees

Comments

@new-on-github
Copy link

I use Pico-RssMaker and like it.

it seems possible to add a image to a rss-item as sub-element:
https://www.rssboard.org/rss-specification#ltenclosuregtSubelementOfLtitemgt
I want to add a image form the meta-tag "image" from my pico-md-yaml-header.

How to do this in php. I tried some versions like:

$rss .= '<enclosure>'; $rss .= $page['image']; $rss .= '</enclosure>';

But this is not working.

My question now is: How to access the page-meta-data via php?

It would be really nice if you could help me with this question.

Btw thanks a lot for the Pico-RssMaker!

@MattByName
Copy link
Owner

hi thanks for raising an issue. I can take a look this weekend.

@MattByName MattByName self-assigned this Apr 23, 2024
@new-on-github
Copy link
Author

new-on-github commented Apr 23, 2024

Thanks a lot for your very quick reply. This would be amazing!

I also tried:

$rss .= '<enclosure>';
$rss .= $meta['image'];
$rss .= '</enclosure>';

without success.

@MattByName
Copy link
Owner

Unfortunately, I've had trouble getting Pico to run at all- I don't actually use it anymore. I think what you'd need is to make sure image is a url to the image, and then add either:

$rss .= '<enclosure url="';
$rss .= $meta['image'];
$rss .= '"/>';

or

$rss .= '<enclosure url="';
$rss .= $page.meta['image'];
$rss .= '"/>';

or

$rss .= '<enclosure url="';
$rss .= $page['image'];
$rss .= '"/>';

If you can get it to work, do let me know and I can update the plugin :)

@new-on-github
Copy link
Author

I tried it all. But the rss-file gives always a empty enclosure-item back.
<enclosure url=""/>
I think the problem is, that $page['image']; does not reference to the meta header item image: %assets_url%/.... To get the time with pico-rssmaker you also not call $page['date']; but $page['time'];. Maybe there is a function which gets the meta-data and puts it somewhere else...

@MattByName
Copy link
Owner

Perhaps image is a keyword? Could you try renaming it to rssimage?

@new-on-github
Copy link
Author

Thanks for this idea. But this seems not to be the problem. I will have to think about it or ask somewhere else. Thanks a lot for your help to this point!

@new-on-github
Copy link
Author

With some help from the pros
picocms/Pico#698
it works now with the following code:

$rss .= '<enclosure url="';
$rss .= str_replace('%assets_url%', $this->baseURL."assets", $page['meta']['image']);
$rss .= '"/>';

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants