🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

Summary of Methods to Automatically Add Watermarks When Uploading Images in WordPress

Hello everyone, I am Brother Leifeng. Today, I will talk to you aboutAdding Watermarks to Images in WordPressplugin introductions and methods. Adding watermarks to images isn't technically complex; it's done to prevent image theft on one hand and to increase website visibility on the other.

Recommended Plugins for Adding Watermarks to Uploaded Images in WordPress

If manually adding watermarks to each image is troublesome for you, using a plugin can help automate the process. There are many plugins for automatically adding watermarks on the WordPress platform. Here, I recommend two plugins that I have used with good results.

Plugin Recommendation 1: DX-Watermark

DX-Watermark is a very oldImage Watermarkplugin. Although the author hasn't updated it for 6 years, everything works normally.Supports adding text watermarks and image watermarks. Features supported by DX-Watermark:
  1. Type: Can choose between text or image watermark types, default is text.
  2. Ignore: Does not add a watermark when the image size is smaller than the set value.
  3. Position: Set the watermark to one of 9 positions, default is bottom right.
  4. Horizontal Adjustment, Vertical Adjustment: Adjust the horizontal and vertical offset of the watermark. Negative values indicate left or upward offset.
  5. Font: Due to the large size of font files, the plugin only includes a few built-in fonts. Users can upload .ttf font files to the wp-content/uploads/dw-uploads/fonts/ directory.
  6. Text: Enter the text to be displayed as the watermark.
  7. Size: Enter the display size for the text watermark.
  8. Color: Select the color of the text watermark from the pop-up color palette.
  9. Transparency: 0 indicates fully transparent, 100 indicates opaque.
  10. The plugin backend provides a preview function, allowing users to preview the effect before saving.
Download Link

Plugin Recommendation 2: image-watermark

The highlight feature of image-watermark is that it canadd watermarks to your previously uploaded images as well.Functionally, it also supports setting the watermark position and controlling transparency. Features supported by image-watermark:
  1. Select watermark position;
  2. Adjustable transparency;
  3. Both old and newly uploaded images can be watermarked;
  4. Disable right-click copying of images.
Download LinkLocalized version of image-watermark download address:https://www.lanzous.com/i6jzuni

There are several similar plugins, all largely similar. The two mentioned above are considered quite good by users and are free.

Plugin Recommendation 3: WPWaterMark

WPWaterMark is a plugin for adding watermarks to WordPress, created by the Chinese blogger Lao Jiang, and is fully in Chinese.
  1. Based on the WordPress platform and provided free to users, it enhances image watermarking functionality to prevent theft of articles and images, at least retaining the watermark to strengthen anti-theft capabilities;
  2. Offers three effects to choose from: nine-grid, random nine-grid, and full-coverage watermark, making it one of the few plugins currently available with such features;
  3. The Light Watermark plugin supports setting text and image watermarks, and can configure common functions like rotation angle and transparency.
Download Link github download

How to Add Watermarks to Uploaded Images in WordPress Without a Plugin:

If you think installingWordPress Pluginwastes resources, you can also use the method below to manually create a file to automatically add image watermarks (the principle is actually the same as a plugin). 1. Create a 'class' folder in the theme directory, then place theimage.phpfile inside. 2. Open the functions.php file and add the following code: Reference:Safe method to add code to the functions.php file: Code Snippets
/**
* WordPress上传图片添加水印
*/
function uimoban_watermark($attachment_ID)
{
$attachment = get_post($attachment_ID);
switch($attachment->post_mime_type){
case 'image/jpeg':
case 'image/png':
case 'image/gif':
require THEME_FILES . '/class/image.php';
$image = new image(true);
$image->set('watermark.png', 1);
$image->watermark($attachment->guid);
break;
default:return ;
}
}
add_action('add_attachment', 'uimoban_watermark');
Explanation:$image->set('watermark.png', 1);In this line, „watermark.png“ specifies the watermark image, which should be consistent with the watermark.png file in the data/watermark/ directory from the first step„s code. Of course, you can modify it. The “1„ represents the watermark position.

How to Add Watermarks with Upyun/Qiniu in WordPress:

Some users utilize image hosting services like Upyun/Qiniu. Upyun/Qiniu themselves support watermark settings. To make WordPress call the watermarked images, the following method is required.

Upyun Automatic Watermark Addition

1. Open the functions.php file and add the following code:
/**
* 又拍云图片添加水印
*/
function fa_hack_image_url($matches) {
    $prefix = '!boob';// 自定义版本或者水印字符串
    return $matches[1] . $matches['2'] . $prefix;
}

function fa_image_add_watermelon( $content ){
    $content = preg_replace_callback("/(]*src *= *[\"']?)([^\"']*)/i", 'fa_hack_image_url' , $content);
    return $content;
}
add_filter('the_content','fa_image_add_watermelon');
2. Then set the Upyun watermark rule, configuring the watermark within the thumbnail creation settings.The generated watermark URL can be manually constructed:/watermark/url/base64-encoded-watermark-path/align/southeastThe watermark path needs to be base64 encoded. For example, if the path is /watermark.png, after base64 encoding it becomes L3dhdGVybWFyay5wbmc=. The suffix to be added to the image is then:!/watermark/url/L3dhdGVybWFyay5wbmc=/align/southeast'align' is followed by the direction, which you can adjust according to your needs. Of course, the simplest way is to set it directly when creating the new rule.

Qiniu Automatic Watermark Addition

1. Open the functions.php file and add the following code:
add_filter('the_content', 'QiNiuThumbnail');
function QiNiuThumbnail($content) {
global $post;
$pattern ="//i";
/* 下面这行代码中的300表示缩略图的大小,请根据实际需求修改即可 */
$replacement = '';
$content = preg_replace($pattern, $replacement, $content);
/* 此处预留位置,可删除 */
return $content;
}
PS: In the code above,?imageMogr2/thumbnail/300xreplace with the desired characters to complete the image processing. 2. In the Qiniu backend, create a new image style, then create an image watermark style, which can also be a text watermark.The above methods referenceZhang Ge's Blogand fatesinger. If you don't mind the trouble,you can also manually add watermarks to images, using online watermarking tools or Photoshop, because sometimes automatic watermarking might cover important parts of the image. For batch watermarking images on a computer, you can use the software XnConvert:How to Batch Process Images on Mac: Resize, Add Watermarks, Rotate(There is a Windows version; the article originally wrote about the Mac version.)

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow