Channel image uses absolute URL, but episode image uses relative URL.

Created on 20 December 2021, almost 3 years ago
Updated 1 April 2024, 9 months ago

Problem/Motivation

The channel image uses an absolute URL, but episode image uses a relative URL. This should be made consistent.

Steps to reproduce

A sample view demonstrating the problem is attached β†’ .

Sample RSS output:

<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xml:base="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <language>en</language>
    <title>SAUK 2</title>
    <description><![CDATA[kanaal twee]]></description>
    <lastBuildDate>Tue, 07 Dec 2021 00:50:00 +0200</lastBuildDate>
    <author>Dolf</author>
    <itunes:author>Dolf</itunes:author>
    <itunes:summary><![CDATA[kanaal twee]]></itunes:summary>
    <itunes:image href="http://localhost:8083/sites/default/files/2021-12/Colorful_Square_Background.jpg" />
    <image><url>http://localhost:8083/sites/default/files/2021-12/Colorful_Square_Background.jpg</url><link>http://localhost:8083</link><title>SAUK 2</title></image>
    <generator>Dolf se Podsender</generator>
    <copyright />
    <itunes:owner><itunes:name>Dolf</itunes:name><itunes:email>rudolfbyker@gmail.com</itunes:email></itunes:owner>
    <link>http://localhost:8083/podcast/6</link>
    <itunes:category text="Religion &amp; Spirituality"><itunes:category text="Christianity"/></itunes:category>
      <item>
  <title>ep2</title>
  <pubDate>Tue, 07 Dec 2021 00:50:00 +0200</pubDate>
    <dc:creator>Podsender Admin</dc:creator>
    <guid isPermaLink="true">http://localhost:8083/node/8</guid>
    <itunes:image href="/sites/default/files/2021-12/duck.jpg" />
    <enclosure url="http://localhost:8083/sites/default/files/2021-12/test_0.mp3" length="201151" type="audio/mpeg" />
    <itunes:title>ep2</itunes:title>
    <link>http://localhost:8083/node/8</link>
    <description><![CDATA[<p>episode twee</p>
]]></description>
    <itunes:author>Dolf</itunes:author>
    <itunes:summary><![CDATA[<p>episode twee</p>
]]></itunes:summary>
    </item>
<item>
  <title>ep1</title>
  <pubDate>Tue, 07 Dec 2021 00:49:39 +0200</pubDate>
    <dc:creator>Podsender Admin</dc:creator>
    <guid isPermaLink="true">http://localhost:8083/node/7</guid>
    <itunes:image />
    <enclosure url="http://localhost:8083/sites/default/files/2021-12/dolf_0.mp3" length="327887" type="audio/mpeg" />
    <itunes:title>ep1</itunes:title>
    <link>http://localhost:8083/node/7</link>
    <description><![CDATA[]]></description>
    <itunes:author>Dolf</itunes:author>
    <itunes:summary><![CDATA[]]></itunes:summary>
    </item>

  </channel>
</rss>

Proposed resolution

Both channel and episode should use absolute URLs for the images.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΏπŸ‡¦South Africa rudolfbyker South Africa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States sandrymend

    Adding this patch to make consistent absolute URLs to channel content.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    Moved the example View into an attached file. This issue was almost impossible to read for anyone with all that inline code at the top. πŸ˜… Scrolling on a phone would have been extremely painful, and I can only imagine the horror of landing here with a screen reader. 😬

    Hopefully this issue is now easier for everyone to contribute to, since I agree this is a bug we should fix.

    Since there's a patch in #2, moving to Needs review.

    Thanks!
    -Derek

  • Status changed to Needs work over 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain rodrigoaguilera Barcelona

    The approach seems right.

    I prefer if you inject just the request stack and make the constructor more simple.
    Here are some reasons why that way is better:
    https://mglaman.dev/blog/dependency-injection-anti-patterns-drupal

  • πŸ‡ΊπŸ‡ΈUnited States dww

    Hah, funny timing. I was just looking at this issue again.

    I'm not sure I love hard-coding the request stack host and port like that.
    It wouldn't handle it when a string actually does start as absolute (for whatever reason).
    It won't consistently work for sites installed in subdirectories.

    I think converting the value to a Url object and setting it to be absolute is safer.

    Also means we don't have to mess with any DI changes at all.

    Thoughts?
    -Derek

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States dww
  • πŸ‡ΊπŸ‡ΈUnited States dww

    Probably scope creep, but I noticed that the channel image handling is like so:

        $image_url = (
          UrlHelper::isExternal($image_field_value) ?
          $image_field_value :
          \Drupal::request()->getSchemeAndHttpHost() . $image_field_value
        );
        $parsed_image_field = parse_url($image_url);
        ...
    

    Seems like we probably want to clean all this up to just use a Url object, too. Should that happen as part of this issue, or would the maintainers prefer handling that as a follow-up?

    Thanks,
    -Derek

  • πŸ‡ͺπŸ‡ΈSpain rodrigoaguilera Barcelona

    I think using the Url object is better so if you want to go ahead with that change I will commit it along this.

  • Status changed to Needs work 9 months ago
  • πŸ‡ͺπŸ‡ΈSpain pcambra Asturies

    Setting to the right state, I've changed code around this in other issues so probably a rebase is needed.

Production build 0.71.5 2024