Fix multiple style when images are repeated
parent
f54028bd1e
commit
f4d11b2e55
|
@ -390,6 +390,7 @@ function oss_setting_content_style($content)
|
||||||
if (!empty($option['style'])) {
|
if (!empty($option['style'])) {
|
||||||
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $images);
|
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $images);
|
||||||
if (!empty($images) && isset($images[1])) {
|
if (!empty($images) && isset($images[1])) {
|
||||||
|
$images[1] = array_unique($images[1]);
|
||||||
foreach ($images[1] as $item) {
|
foreach ($images[1] as $item) {
|
||||||
if(strpos($item, $option['upload_url_path']) !== false){
|
if(strpos($item, $option['upload_url_path']) !== false){
|
||||||
$content = str_replace($item, $item . $option['style'], $content);
|
$content = str_replace($item, $item . $option['style'], $content);
|
||||||
|
@ -407,6 +408,7 @@ function oss_setting_post_thumbnail_style( $html, $post_id, $post_image_id )
|
||||||
if (!empty($option['style']) && has_post_thumbnail()) {
|
if (!empty($option['style']) && has_post_thumbnail()) {
|
||||||
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $html, $images);
|
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $html, $images);
|
||||||
if (!empty($images) && isset($images[1])) {
|
if (!empty($images) && isset($images[1])) {
|
||||||
|
$images[1] = array_unique($images[1]);
|
||||||
foreach ($images[1] as $item) {
|
foreach ($images[1] as $item) {
|
||||||
if(strpos($item, $option['upload_url_path']) !== false){
|
if(strpos($item, $option['upload_url_path']) !== false){
|
||||||
$html = str_replace($item, $item . $option['style'], $html);
|
$html = str_replace($item, $item . $option['style'], $html);
|
||||||
|
|
Loading…
Reference in New Issue