Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It appears in the 8.x-5.0-beta8, that the option for "Direct URL to media file entity" for Media matcher broke and is returning the media entity url instead of the media file.
I believe there is just a forgotten return statement in Drupal\linkit\Plugin\Linkit\Substitution\Media substitution class. I will work on a patch this evening.
Comment | File | Size | Author |
---|---|---|---|
#11 | 3069481-11.patch | 1.82 KB | acbramley |
#11 | 3069481-11-test-only.patch | 1.23 KB | acbramley |
Comments
Comment #2
pingevt CreditAttribution: pingevt at Bluecadet commentedLooks like when the related issue was fixed there was just a missed return value and automatically goes to the fallback of the url for the media entity.
Comment #3
pingevt CreditAttribution: pingevt at Bluecadet commentedLooks like this is a more complicated issue than I first thought...
For Core 8.7.x in media, they added a checkbox in the settings (/admin/config/media/media-settings) to allow /media/{id}. It appears this should be unchecked for new site. I'm not entirely sure why it is checked on my site. I originally thought it was setting that to true on old sites upgrading, but I believe it remains unchecked on old site.
The problem as described in the related issue I don't think is 100% accurate. depending on that setting the canonical url is different. If checked, /media/{id}, if not checked, /media/{id}/edit.
So, I believe this patch works if that setting is set for backwards compatibility. If it is unchecked, current code works fine.
At the moment, I'm not 100% positive how this should be handled in this module. If a maintainer or others want to weigh in, I'm more than happy to work on patches. Or if I'm completely off base on this error please let me know.
My main issue is my old and new content in the wysiwyg still creates links as /media/{id}. If I change the setting, all my content (thousands of nodes) will now have bad links. I can easily do a little DB manipulation, but I'd rather not... if there is a better solution.
Comment #4
larowlan+1 I think this is just a bug in linkit.
Comment #5
alisonPatch works for me, on LinkIt 8.x-5.0-beta9 -- thank you!!
Comment #6
jddh CreditAttribution: jddh as a volunteer commented+1 — thanks team!
Comment #7
dench0 CreditAttribution: dench0 commentedYea, it is for sure bug in linkit code.
Comment #8
phuang07 CreditAttribution: phuang07 as a volunteer commentedThe patch work! thanks.
Comment #9
Kasey_MK CreditAttribution: Kasey_MK commentedThanks, works for me, even though I do have "Standalone media URL" checked on /admin/config/media/media-settings
Comment #10
acbramley CreditAttribution: acbramley at PreviousNext commentedThe fact this went unnoticed tells me there's probably not sufficient test coverage? Shouldn't we add it here?
Comment #11
acbramley CreditAttribution: acbramley at PreviousNext commentedHere's an updated patch with test modifications.
Comment #12
acbramley CreditAttribution: acbramley at PreviousNext commentedFailure seems unrelated, HEAD is also failing https://www.drupal.org/pift-ci-job/1442921
Comment #14
anonThanks for the patch and the test patch.