Skip to content

Commit

Permalink
文章中匹配图片的正则修复
Browse files Browse the repository at this point in the history
  • Loading branch information
zdhxiong committed Sep 8, 2020
1 parent d092994 commit d9de6f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Service/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public function update(string $key, array $data): void
public function updateItemRelated($itemType, $itemId, $markdownContent): void
{
// 从 markdown 文本中提取链接
preg_match_all("/!\[([^_]+?)_release\.(.+?)\]/", $markdownContent, $matches);
preg_match_all("/\/([0-9a-z]{32})(_release)?\.(jpg|png|gif|jpeg)/i", $markdownContent, $matches);

$count = count($matches[0]);
$keys = [];

for ($i = 0; $i < $count; $i++) {
$keys[] = $matches[1][$i] . '.' . $matches[2][$i];
$keys[] = $matches[1][$i] . '.' . $matches[3][$i];
}

if ($keys) {
Expand Down

0 comments on commit d9de6f1

Please sign in to comment.