Skip to content
FacebookTwitterPinterest
HOWTOHOWTO
  • All
    • Tips
      • Google
      • Facebook
      • Tiktok
    • Instruct
      • What is Q&A?
      • Taobao
    • WordPress
      • Code
      • Plugins
      • Themes
        • Flatsome
        • Theme Nevo
  • Share
    • WordPress
    • Code
    • Plugins
    • Tips
    • Windows
    • Apple
    • Graphics
    • Experience
  • Graphics documents
    • illustrator
    • Sketchup
    • Coreldraw
    • 3ds max
    • Enscape
    • Photoshop
    • Graphics Plugin
  • Course
    • Photoshop course
    • illustrator course
    • Coreldraw course
    • Edit video course
    • Course Sketchup
    • Autocad course
    • Website management course
  • Service
  • Software
    • Windows
      • Tips
      • Office
      • Necessary
      • Tools
    • Apple
  • Game
  • News
    • Technology
    • Review
HOWTOHOWTO
  • Home > 
  • Wordpress > 
  • Code to automatically save images to hot when copying images from other pages

Code to automatically save images to hot when copying images from other pages

By How To 01/01/2026 0 631 Views
Code to automatically save images to hot when copying images from other pages
Article categories

Code to automatically save images to hot when copying images from other pages. This feature helps automatically save images that you have copied from another website to the hot folder on your computer.

When you copy an image from the website, the code will automatically recognize the copying of the image and save it to the hot folder you specified earlier. This makes it easy to organize and quickly access images you've copied from the web without having to save them manually.

You can also find more content in good code or wordpress code ours

Code to automatically save images to hot when copying images from other pages

This code is functional.

  • 1 as the title says it can automatically save images to our hotbox when we copy images from another page.
  • Automatically rename files according to Seo standards when saving to your hotline

For example, when copying another party's file name, it can be abcxyz.jpg Change the title of the article: title-de-bait-viet-xxx.jpg

In there xxx is a series of jumping numbers to avoid duplicates

Experience: Let the code to automatically save images work effectively. You should give the article a title first and then copy the images and content. Now the code will automatically rename the file according to our title, which will be better for SEO

Note: This code is used to execute on PHP or WordPress website platform

  • Website design service according to SEO standards, good conversion
  • Website management services effectively take care of websites
  • Learn about graphic design services

The steps to insert code to automatically save images to hot are as follows.

Step 1: Log in to your account

You need to log in to an account with administrator rights to use it

Step 2: Copy the code below

Copy the code below then continue to step 3 to paste the code into the website

/* Code Tự động lưu ảnh vào hots */
/* author: https://how.congdongso.net */
class Auto_Save_Images{
function __construct(){ 
add_filter( 'content_save_pre',array($this,'post_save_images') ); }
function post_save_images( $content ){
if( ($_POST['save'] || $_POST['publish'] )){
set_time_limit(240);
global $post;
$post_id=$post->ID;
$preg=preg_match_all('/<img.*?src="(.*?)"/',stripslashes($content),$matches);
if($preg){
foreach($matches[1] as $image_url){
if(empty($image_url)) continue;
$pos=strpos($image_url,$_SERVER['HTTP_HOST']);
if($pos===false){
$res=$this->save_images($image_url,$post_id);
$replace=$res['url'];
$content=str_replace($image_url,$replace,$content);}}}}
remove_filter( 'content_save_pre', array( $this, 'post_save_images' ) );
return $content;}
function save_images($image_url,$post_id){
$file=file_get_contents($image_url);
$post = get_post($post_id);
$posttitle = $post->post_title;
$postname = sanitize_title($posttitle);
$im_name = "$postname-$post_id.jpg";
$res=wp_upload_bits($im_name,'',$file);
$this->insert_attachment($res['file'],$post_id);
return $res;}
function insert_attachment($file,$id){
$dirs=wp_upload_dir();
$filetype=wp_check_filetype($file);
$attachment=array(
'guid'=>$dirs['baseurl'].'/'._wp_relative_upload_path($file),
'post_mime_type'=>$filetype['type'],
'post_title'=>preg_replace('/.[^.]+$/','',basename($file)),
'post_content'=>'',
'post_status'=>'inherit'
);
$attach_id=wp_insert_attachment($attachment,$file,$id);
$attach_data=wp_generate_attachment_metadata($attach_id,$file);
wp_update_attachment_metadata($attach_id,$attach_data);
return $attach_id;}}
new Auto_Save_Images();

Step 3: Access the link to paste the code

After you have logged in and copied the code, follow the link below to paste the code into your website

Go to Interface > Theme file editor > look to the left and find the section Function.php. 

Code to automatically save images to hot
Link to paste the code

Some of your websites may not be found, maybe they are using a child theme or a theme that has not created this section yet, please switch to the parent theme.

Code to automatically save images to hot
Convert theme to display Function.php

Step 4: Check the results

To check Code to automatically save images to hot when copying images from other pages Whether it works or not, please do the following:

Create an article with the title of your choice > Copy images and content from another site to this article. At this time, when you check, you still see that the link is from the other party. You proceed to Save the draft of the website and it will automatically reload. Now you just need to check the results again.

Summary.

I recently shared with you the passage The code automatically saves images to hot when copying images from another page. At the same time, detailed instructions on how to insert and use that code. Hope this article will be really useful to you.

If you find it useful, don't forget 5* rating and follow Facebook channel us to be updated with the latest news.

Source: Collector

Tags : Tags Code   Code to save images to hot when copying images from another page
Share
FacebookShare on FacebookpinterestShare on PinterestMessengerShare on Facebook Messenger
twitterShare on TwitterlinkedinShare on LinkedinvkShare on VkredditShare on ReddittumblrShare on TumblrvideoShare on Viadeobuffer. bufferShare on Bufferpocket. pocketShare on PocketwhatsappShare on WhatsappViberShare on ViberemailShare on EmailskypeShare on SkypediggShare on DiggmyspaceShare on MyspacebloggerShare on Blogger YahooMailShare on Yahoo mailtelegramShare on Telegram gmailShare on GmailAmazonShare on AmazonSMSShare on SMS

How To

A person who is passionate about sharing knowledge from life. Common knowledge in life. Sharing is my passion. Hopefully my knowledge will bring many benefits to you

Related articles

Code to automatically save images to hot when copying images from other pages

How to add fonts to wordpress text editor area

By How To 04/12/2025 0

How to add fonts to wordpress. When you type…

Code to automatically save images to hot when copying images from other pages

Fix Failed to send buffer of zlib output compression error on wordpress

By thindv 22/11/2025 0

The error "Failed to send buffer of zlib output compression" usually…

Leave a Comment Cancel reply

Categories Adobe Photoshop Remove tool in photoshop

Remove tool in photoshop

27/03/2026
4 Ways to create speed effects in Photoshop

4 Ways to create speed effects in Photoshop

27/03/2026
Graphic Design

Graphic Design The art of creating appeal

27/02/2026
What is google plays app? Is installation necessary?

What is google plays app? Is installation necessary?

24/02/2026
create flatsome slider

How to create a slider that runs super smoothly on flatsome

05/01/2026

Recent comments

  • male2 years ago
    On How to create a fade effect in Photoshop
    Great
  • phat phat2 years ago
    On Who is 5SMedia?
    Useful article
  • Minh Anh3 years ago
    On How to create basic materials in vray Sketchup
    Very good, admin
Copyright © 2026 HOWTO - Powered by HOWTO

5SMedia.net | hocdohoacaptoc.com | huongdansudung.vn | webantam.com

Back to Top
Hello!
  • All
    • Tips
      • Google
      • Facebook
      • Tiktok
    • Instruct
      • What is Q&A?
      • Taobao
    • WordPress
      • Code
      • Plugins
      • Themes
        • Flatsome
        • Theme Nevo
  • Share
    • WordPress
    • Code
    • Plugins
    • Tips
    • Windows
    • Apple
    • Graphics
    • Experience
  • Graphics documents
    • illustrator
    • Sketchup
    • Coreldraw
    • 3ds max
    • Enscape
    • Photoshop
    • Graphics Plugin
  • Course
    • Photoshop course
    • illustrator course
    • Coreldraw course
    • Edit video course
    • Course Sketchup
    • Autocad course
    • Website management course
  • Service
  • Software
    • Windows
      • Tips
      • Office
      • Necessary
      • Tools
    • Apple
  • Game
  • News
    • Technology
    • Review
EN
EN
VI
Hello!

  • Lost your password ?