


I would like to ask if the link conversion is not written in the IMG tag?
<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\s[^>]*'.$pattern_image_url.'.*?>?<[^>]+a>/i'; $preg = preg_match($pattern, $content, $matches); if ($preg) { if ( $this->save_outside_links == 'yes' ) { if ( preg_match('/<a[^>]*href=\"(.*?)\".*?>/i', $matches[0], $match) ) { $link = $match[1]; $description = '<a href="'.$link.'" 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\s[^>]*'.$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 class="'.$align.'size-'.$size.' wp-image-'.$attachment_id.'" src="'.$src.'" width="'.$width.'" height="'.$height.'"'.$alt.$title.' />'; $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="'.$res['url'].'">'.$img.'</a>'; break; case 'post': $replace = '<a href="'.get_permalink($attachment_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\s[^>]*'.$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; }</code>
The above is the code of a plug-in, which contains link conversion.
I want to prevent it from converting the original image link. Please tell me how to modify it. Don't know PHP very well. Please give me some advice, seniors. Thank you
Reply content:
<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\s[^>]*'.$pattern_image_url.'.*?>?<[^>]+a>/i'; $preg = preg_match($pattern, $content, $matches); if ($preg) { if ( $this->save_outside_links == 'yes' ) { if ( preg_match('/<a[^>]*href=\"(.*?)\".*?>/i', $matches[0], $match) ) { $link = $match[1]; $description = '<a href="'.$link.'" 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\s[^>]*'.$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 class="'.$align.'size-'.$size.' wp-image-'.$attachment_id.'" src="'.$src.'" width="'.$width.'" height="'.$height.'"'.$alt.$title.' />'; $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="'.$res['url'].'">'.$img.'</a>'; break; case 'post': $replace = '<a href="'.get_permalink($attachment_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\s[^>]*'.$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; }</code>
The above is the code of a plug-in, which contains link conversion.
I want to prevent it from converting the original image link. Please tell me how to modify it. Don't know PHP very well. Please give me some advice, seniors. Thank you

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











There are four ways to adjust the WordPress article list: use theme options, use plugins (such as Post Types Order, WP Post List, Boxy Stuff), use code (add settings in the functions.php file), or modify the WordPress database directly.

To build a website using WordPress hosting, you need to: select a reliable hosting provider. Buy a domain name. Set up a WordPress hosting account. Select a topic. Add pages and articles. Install the plug-in. Customize your website. Publish your website.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Importing WordPress source code requires the following steps: Create a sub-theme for theme modification. Import the source code and overwrite the files in the sub-topic. Activate the sub-theme to make it effective. Test the changes to make sure everything works.

You can view the WordPress front-end by logging into the dashboard and switching to the View Sites tab; automate the viewing process with a headless browser; installing the WordPress plugin to preview the front-end within the dashboard; viewing the front-end via a local URL (if WordPress is set locally).

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

WordPress editing dates can be canceled in three ways: 1. Install the Enable Post Date Disable plug-in; 2. Add code in the functions.php file; 3. Manually edit the post_modified column in the wp_posts table.

The steps to create a custom header in WordPress are as follows: Edit the theme file "header.php". Add your website name and description. Create a navigation menu. Add a search bar. Save changes and view your custom header.
