Skip to content

Commit

Permalink
修复bug: 给图片加上alt/title
Browse files Browse the repository at this point in the history
title,alt 内容需要双引号
  • Loading branch information
rankment committed Oct 7, 2022
1 parent 5c8234d commit 840363e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ function content_img_add_alt_title($content)
preg_match_all('/<img (.*?)\/>/', $content, $images);
if (!is_null($images)) {
foreach ($images[1] as $index => $value) {
$new_img = str_replace('<img', '<img title=' . $post->post_title . '
alt=' . $post->post_title, $images[0][$index]);
$new_img = str_replace('<img', '<img title="'. $post->post_title . '"
alt="' . $post->post_title .'"', $images[0][$index]);
$content = str_replace($images[0][$index], $new_img, $content);
}
}
Expand Down

0 comments on commit 840363e

Please sign in to comment.