project Websites / Gitlab Issue Listing Script avatar

websites/Gitlab-Issue-Listing-Script#32: Some embedded images don't load

Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.4
Created: 22-Apr-22 07:24


Whilst testing the new RC I've noticed that screenshots in the description of #30 aren't being displayed, but a later screenshot in the comments is.


Toggle State Changes


assigned to @btasker

changed the description

Looking in developer tools, I'm seeing different paths between working and not working:

  • Not working: /uploads/1e7e6db836499d02dc2b7f8dc80218d0/Screenshot_20220421_082234.png
  • working: /issue/websites/Gitlab-Issue-Listing-Script/uploads/a153685e3a5014d1eb5125bf1aa2a050/Screenshot_20220421_195659.png

The path in the comments is relative, whilst the one in the description is absolute:

<img src="uploads/a153685e3a5014d1eb5125bf1aa2a050/Screenshot_20220421_195659.png" alt="Screenshot_20220421_195659">

<img src="/uploads/1e7e6db836499d02dc2b7f8dc80218d0/Screenshot_20220421_082234.png" alt="Screenshot_20220421_082234">

We handle images from within their relevant subsection, so it does need to be relative.

Looking at the markdown that Gitlab's API returns for the issue description, the path is absolute there.


Interestingly though, the same is true of the one in the comments


Ah, comments have some additional processing which the issue description does not

$body = str_replace("](uploads", "](uploads", $body);

I don't remember doing that, but there's our answer.


mentioned in commit 61a6f2a705d0de3d8f1016d4c36d595b52b157bc

Commit: 61a6f2a705d0de3d8f1016d4c36d595b52b157bc 
Author: B Tasker                            
Date: 2022-04-22T08:40:05.000+01:00 


Images within issue descriptions were broken (websites/Gitlab-Issue-Listing-Script#32)

This commit adjusts so that the path is always relative.

We might actually want to make this DRY and build a utility function for handling image embeds

+1 -1 (2 lines changed)