- Issue created by @rjhammond
- πΊπΈUnited States afinnarn
Hello @rjhammond,
I'm still getting my bearings on this codebase, but I just tested on 1.0.2, Drupal 10.1.4, and PHP 8.2 where I do see type and size appending working on the link fields but not in the "content parsing" when I tested on a file media item. I set it to "Redirection" for delivery.
However, I figured out the issue with content parsing, or at least what I'm seeing.
In the "MediaLinkEnhancementsAlterLinks" class, there is a method called "alterLinks". In that method around line #151, there is a function call to get the HTML of the full link so it can be checked in replacement further down in the code.
// Get the full link to replace before we modify it. $full_link = $link->C14N();
If you update that line to:
// Get the full link to replace before we modify it. $full_link = $doc->saveHTML($link);
The problem was the HTML attributes of the anchor tag were re-arranged by "$link->C14N()". So when the strings were compared in "$content = str_replace($full_link, $new, $content);" the anchor link didn't match exactly and the file extension wasn't added. With "$doc->saveHTML($link)" the attributes are in order so the content matches and is replaced.
I will work on a MR for this, but if you can, please try changing that code to see if content parsing works.
- πΊπΈUnited States afinnarn
I errantly created an issue fork here, but I'm still not sure of your issue.
Instead, I created another issue for what I mentioned with content parsing and made a MR here if you want to test: https://www.drupal.org/project/media_link_enhancements/issues/3394047 π Content parsing broken Needs review
- π¨π¦Canada rjhammond
Thank you very much @afinnarn!
Your patch in #3394047 worked for me. I'm flagging this for closure as a duplicate of:
https://www.drupal.org/project/media_link_enhancements/issues/3394047 π Content parsing broken Needs review - Status changed to Closed: duplicate
about 1 year ago 4:35pm 16 October 2023 - πΊπΈUnited States afinnarn
Sounds good to me. I will close this issue as a duplicate.
- πΊπΈUnited States afinnarn
@rjhammond Can you review the duplicate issue, if you have time, so we can call it RTBC?