Skip to content

Commit 4b6e8f6

Browse files
committed
Corrected classes and search patterns
1 parent 3a5a830 commit 4b6e8f6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function execute(string $content): array
6363
preg_match_all($pattern, $content, $matches, PREG_PATTERN_ORDER);
6464

6565
if (!empty($matches[1])) {
66-
$paths += array_unique($matches[1]);
66+
$paths = array_merge($paths, array_unique($matches[1]));
6767
}
6868
}
6969

@@ -81,6 +81,8 @@ private function getAssetsByPaths(array $paths): array
8181
$assets = [];
8282

8383
foreach ($paths as $path) {
84+
$path = htmlspecialchars_decode($path);
85+
$path = trim($path, '"\'');
8486
try {
8587
/** @var AssetInterface $asset */
8688
$asset = $this->getMediaAssetByPath->execute($this->getPathStartingWithSlash($path));
@@ -101,6 +103,10 @@ private function getAssetsByPaths(array $paths): array
101103
*/
102104
private function getPathStartingWithSlash(string $path): string
103105
{
104-
return '/' . ltrim($path, '/');
106+
$normalizedPath = ltrim($path, '/');
107+
if (strpos($normalizedPath, '/')) {
108+
return $normalizedPath;
109+
}
110+
return '/' . $normalizedPath;
105111
}
106112
}

app/code/Magento/MediaContentCms/Observer/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\MediaContentCms\Observer;
99

10-
use Magento\Cms\Block\Block as CmsBlock;
10+
use Magento\Cms\Model\Block as CmsBlock;
1111
use Magento\Framework\Event\Observer;
1212
use Magento\Framework\Event\ObserverInterface;
1313
use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface;

app/code/Magento/MediaContentCms/etc/media_content.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<search>
1010
<patterns>
1111
<pattern name="media_gallery">/{{media url="?(.*?)"?}}/</pattern>
12+
<pattern name="wysiwyg">/src=".*\/media\/(.*?)"/</pattern>
1213
</patterns>
1314
</search>
1415
</config>

0 commit comments

Comments
 (0)