请教一下链接转换不是写在IMG标签内吗?
<code>public function format($image_url, $res, $content) { $no_match = false; $attachment_id = $res['id']; $url_path = str_replace(basename($res['file']), '', $res['url']); $size = isset($res['sizes'][$this->format['size']]) ? $this->format['size'] : 'full'; if ($size == 'full') { $src = $res['url']; $width = $res['width']; $height = $res['height']; } else { $src = $url_path . $res['sizes'][$size]['file']; $width = $res['sizes'][$size]['width']; $height = $res['sizes'][$size]['height']; } $pattern_image_url = $this->encode_pattern($image_url); $preg = false; if ($this->keep_outside_links=='no') { $pattern = '/<a><img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>?]+a>/i'; $preg = preg_match($pattern, $content, $matches); if ($preg) { if ( $this->save_outside_links == 'yes' ) { if ( preg_match('/</a><a>]*href=\"(.*?)\".*?>/i', $matches[0], $match) ) { $link = $match[1]; $description = '</a><a href="'.%24link.'" target="_blank" rel="nofollow">'.__('Original Link', 'qqworld_auto_save_images').'</a>'; $description = apply_filters('qqworld-auto-save-images-save-outsite-link', $description, $link); $args = array( 'ID' => $attachment_id, 'post_content' => $description ); wp_update_post($args); } } $args = $this->set_img_metadata($matches[0], $attachment_id); } } if (!$preg) { $pattern = '/<img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>/i'; if ( preg_match($pattern, $content, $matches) ) { $args = $this->set_img_metadata($matches[0], $attachment_id); } else { $pattern = '/'.$pattern_image_url.'/i'; $no_match = true; } } $alt = isset($args['alt']) ? ' alt="'.$args['alt'].'"' : ''; $title = isset($args['title']) ? ' title="'.$args['title'].'"' : ''; $align = $this->auto_caption == 'yes' ? '' : 'align'.$this->format_align_to.' '; $img = '<img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" . style="max-width:90%".$width.'" height="'.$height.'" alt="请教一下链接转换不是写在IMG标签内吗?" >'; $link_to = $this->keep_outside_links=='no' ? $this->format['link-to'] : 'none'; switch ($link_to) { case 'none': $replace = $img; break; case 'file': $replace = '<a href="'.%24res%5B'url'%5D.'">'.$img.'</a>'; break; case 'post': $replace = '<a href="'.get_permalink(%24attachment_id).'">'.$img.'</a>'; break; } if ($no_match) $replace = $res['url']; else if ($this->auto_caption == 'yes') $replace = '[caption id="attachment_'.$attachment_id.'" align="align'.$this->format_align_to.'" width="'.$width.'"]' . $replace . ' ' . (isset($args['alt']) ? $args['alt'] : '') . '[/caption]'; $replace .= str_replace( '[Attachment ID]', $res['id'], $this->additional_content['after'] ); if ( $this->keep_outside_links=='yes' ) { $patt = '/<a><img alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>?]+a>/i'; if ( preg_match($patt, $content, $match) ) { $string = $match[0]; $pos = strpos($string, '>'); $string = substr_replace($string, ' rel="nofollow">', $pos, 1); $content = preg_replace($patt, $string, $content); } } $content = preg_replace($pattern, $replace, $content); return $content; }</a></code>
以上是一个插件的代码,里面写了链接转换。
我想阻止它将原本的图片链接转换。请问应该怎么修改。不是很懂PHP。请教下各位前辈 谢谢
回复内容:
<code>public function format($image_url, $res, $content) { $no_match = false; $attachment_id = $res['id']; $url_path = str_replace(basename($res['file']), '', $res['url']); $size = isset($res['sizes'][$this->format['size']]) ? $this->format['size'] : 'full'; if ($size == 'full') { $src = $res['url']; $width = $res['width']; $height = $res['height']; } else { $src = $url_path . $res['sizes'][$size]['file']; $width = $res['sizes'][$size]['width']; $height = $res['sizes'][$size]['height']; } $pattern_image_url = $this->encode_pattern($image_url); $preg = false; if ($this->keep_outside_links=='no') { $pattern = '/<a><img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>?]+a>/i'; $preg = preg_match($pattern, $content, $matches); if ($preg) { if ( $this->save_outside_links == 'yes' ) { if ( preg_match('/</a><a>]*href=\"(.*?)\".*?>/i', $matches[0], $match) ) { $link = $match[1]; $description = '</a><a href="'.%24link.'" target="_blank" rel="nofollow">'.__('Original Link', 'qqworld_auto_save_images').'</a>'; $description = apply_filters('qqworld-auto-save-images-save-outsite-link', $description, $link); $args = array( 'ID' => $attachment_id, 'post_content' => $description ); wp_update_post($args); } } $args = $this->set_img_metadata($matches[0], $attachment_id); } } if (!$preg) { $pattern = '/<img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>/i'; if ( preg_match($pattern, $content, $matches) ) { $args = $this->set_img_metadata($matches[0], $attachment_id); } else { $pattern = '/'.$pattern_image_url.'/i'; $no_match = true; } } $alt = isset($args['alt']) ? ' alt="'.$args['alt'].'"' : ''; $title = isset($args['title']) ? ' title="'.$args['title'].'"' : ''; $align = $this->auto_caption == 'yes' ? '' : 'align'.$this->format_align_to.' '; $img = '<img src="/static/imghw/default1.png" data-src="'.$src.'" class="lazy" . style="max-width:90%".$width.'" height="'.$height.'" alt="请教一下链接转换不是写在IMG标签内吗?" >'; $link_to = $this->keep_outside_links=='no' ? $this->format['link-to'] : 'none'; switch ($link_to) { case 'none': $replace = $img; break; case 'file': $replace = '<a href="'.%24res%5B'url'%5D.'">'.$img.'</a>'; break; case 'post': $replace = '<a href="'.get_permalink(%24attachment_id).'">'.$img.'</a>'; break; } if ($no_match) $replace = $res['url']; else if ($this->auto_caption == 'yes') $replace = '[caption id="attachment_'.$attachment_id.'" align="align'.$this->format_align_to.'" width="'.$width.'"]' . $replace . ' ' . (isset($args['alt']) ? $args['alt'] : '') . '[/caption]'; $replace .= str_replace( '[Attachment ID]', $res['id'], $this->additional_content['after'] ); if ( $this->keep_outside_links=='yes' ) { $patt = '/<a><img alt="请教一下链接转换不是写在IMG标签内吗?" >]*'.$pattern_image_url.'.*?>?]+a>/i'; if ( preg_match($patt, $content, $match) ) { $string = $match[0]; $pos = strpos($string, '>'); $string = substr_replace($string, ' rel="nofollow">', $pos, 1); $content = preg_replace($patt, $string, $content); } } $content = preg_replace($pattern, $replace, $content); return $content; }</a></code>
以上是一个插件的代码,里面写了链接转换。
我想阻止它将原本的图片链接转换。请问应该怎么修改。不是很懂PHP。请教下各位前辈 谢谢

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

有四種方法可以調整 WordPress 文章列表:使用主題選項、使用插件(如 Post Types Order、WP Post List、Boxy Stuff)、使用代碼(在 functions.php 文件中添加設置)或直接修改 WordPress 數據庫。

要使用 WordPress 主機建站,需要:選擇一個可靠的主機提供商。購買一個域名。設置 WordPress 主機帳戶。選擇一個主題。添加頁面和文章。安裝插件。自定義您的網站。發布您的網站。

更換 WordPress 主題頭部圖片的分步指南:登錄 WordPress 儀錶盤,導航至“外觀”>“主題”。選擇要編輯的主題,然後單擊“自定義”。打開“主題選項”面板並尋找“網站標頭”或“頭部圖片”選項。單擊“選擇圖像”按鈕並上傳新的頭部圖片。裁剪圖像並單擊“保存並裁剪”。單擊“保存並發布”按鈕以更新更改。

IIS和PHP可以兼容,通過FastCGI實現。 1.IIS通過配置文件將.php文件請求轉發給FastCGI模塊。 2.FastCGI模塊啟動PHP進程處理請求,提高性能和穩定性。 3.實際應用中需注意配置細節、錯誤調試和性能優化。

導入 WordPress 源碼需要以下步驟:創建子主題以進行主題修改。導入源碼,覆蓋子主題中的文件。激活子主題,使其生效。測試更改,確保一切正常。

可以通過以下方法查看 WordPress 前端:登錄儀錶盤並切換到“查看站點”選項卡;使用無頭瀏覽器自動化查看過程;安裝 WordPress 插件在儀錶盤內預覽前端;通過本地 URL 查看前端(如果 WordPress 在本地設置)。

多次調用session_start()會導致警告信息和可能的數據覆蓋。 1)PHP會發出警告,提示session已啟動。 2)可能導致session數據意外覆蓋。 3)使用session_status()檢查session狀態,避免重複調用。

WordPress 編輯日期可以通過三種方法取消:1. 安裝 Enable Post Date Disable 插件;2. 在 functions.php 文件中添加代碼;3. 手動編輯 wp_posts 表中的 post_modified 列。
