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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pingevt created an issue. See original summary.

pingevt’s picture

Looks 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.

pingevt’s picture

Looks 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.

larowlan’s picture

Status: Active » Reviewed & tested by the community

+1 I think this is just a bug in linkit.

alison’s picture

Patch works for me, on LinkIt 8.x-5.0-beta9 -- thank you!!

jddh’s picture

+1 — thanks team!

dench0’s picture

Yea, it is for sure bug in linkit code.

phuang07’s picture

The patch work! thanks.

Kasey_MK’s picture

Thanks, works for me, even though I do have "Standalone media URL" checked on /admin/config/media/media-settings

acbramley’s picture

The fact this went unnoticed tells me there's probably not sufficient test coverage? Shouldn't we add it here?

acbramley’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.23 KB
1.82 KB

Here's an updated patch with test modifications.

acbramley’s picture

Failure seems unrelated, HEAD is also failing https://www.drupal.org/pift-ci-job/1442921

  • anon committed 0770fbc on 8.x-5.x authored by acbramley
    Issue #3069481 by acbramley, pingevt, anon: "Direct URL to media file...
anon’s picture

Status: Needs review » Fixed

Thanks for the patch and the test patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.