Skip to content

Commit

Permalink
Alter media usage check
Browse files Browse the repository at this point in the history
  • Loading branch information
akasake committed Jun 25, 2024
1 parent de1738a commit 5d5e42b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Service/UsageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,17 @@ protected function getIdsFromText(string $text): array
$mediaIds = [];
$dom = Html::load($text);
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//a[@data-media-file-link]') as $element) {
/* @var \DOMElement $element */
$mediaIds[(int) $element->getAttribute('data-media-file-link')] = 'file';
foreach ($xpath->query('//a[contains(@href,"media/")]') as $element) {
$href = $element->getAttribute('href');
if (!str_contains($href, 'media/')) {
continue;
}

preg_match('/(?<=media\/)\d+/', $href, $matches);

$mid = reset($matches);
/* @var \DOMElement $element */
$mediaIds[$mid] = 'file';
}

return $mediaIds;
Expand Down

0 comments on commit 5d5e42b

Please sign in to comment.