custom watermark video Archives - VdoCipher Blog Secure Video Streaming Thu, 04 Apr 2024 10:04:34 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.5 https://www.vdocipher.com/blog/wp-content/uploads/2016/11/cropped-VdoCipher-logo2-32x32.png custom watermark video Archives - VdoCipher Blog 32 32 Custom variables as watermark on WordPress videos https://www.vdocipher.com/blog/custom-variables-watermark-on-wordpress-videos/ https://www.vdocipher.com/blog/custom-variables-watermark-on-wordpress-videos/#respond Fri, 06 Jan 2023 01:48:27 +0000 https://www.vdocipher.com/blog/?p=361 Please visit Add Text to Videos with Watermark for a detailed introduction to adding a watermark to your videos. This particular blog explains what is going on under the hood of the WP plugin, and is useful only if you are adding your own custom-built variables as part of the watermark. Currently, name, IP, and […]

The post Custom variables as watermark on WordPress videos appeared first on VdoCipher Blog.

]]>
Please visit Add Text to Videos with Watermark for a detailed introduction to adding a watermark to your videos. This particular blog explains what is going on under the hood of the WP plugin, and is useful only if you are adding your own custom-built variables as part of the watermark. Currently, name, IP, and email can be shown as part of the watermark.

Watermark on videos adds extra security for the video from screen capture by adding variables such as email, IP or date information to the videos. Custom variables are now supported in plugin 1.6

Default WordPress fields that can be added

Our plugin has been configured to replace the following strings in the annotation code by default:

  • {name} – Current User display name
  • {email} – Current User email
  • {username} – Current User Login
  • {id} – Current User ID

Till version 1.5 of our WordPress video hosting plugin, watermark on videos could only have a limited number of dynamic variables. With version 1.6, we have now added filter hooks on the annotation code to enable other plugins or themes to change the annotation code.

Custom filter addition to the WordPress hook

You can now add a custom filter to the hook `vdocipher_annotate_preprocess` . Example code for adding custom filter is:

function customfunc($vdo_annotate_code){
 $customVariable = "Hello world";
 $vdo_annotate_code = str_replace('{var1}', $customVariable, $vdo_annotate_code);
 return $vdo_annotate_code;
}

add_filter('vdocipher_annotate_preprocess', 'customfunc');

Display WordPress Default field like User Fullname

An example code to display the full name is as follows:

function customvdofunc($vdo_annotate_code){
    $fullname = "";
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $firstname = $current_user->user_firstname;
        $lastname = $current_user->user_lastname;
        $fullname = $firstname . " " . $lastname;
     }
     $vdo_annotate_code = str_replace('{fullname}', $fullname, $vdo_annotate_code);
     return $vdo_annotate_code;
}
add_filter('vdocipher_annotate_preprocess', 'customvdofunc');

This would replace the string ‘{fullname}’ in the watermark code to the fullname of the logged in user.

JSON Code addition to the VdoCipher WordPress Plugin

The above code enables you to replace the token {var1} with the value of $customVariable. You can then use an annotation code like:

[
{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'{var1}', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}
]

This code on going through the above filter will become

[
{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'Hello world', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}
]

This function can be placed in the functions.php file in your theme. It is recommended to create a child theme before making such edits.

Example Steps to configure custom field “Phone number” as a watermark

You can configure user-specific details like “phone numbers” as a watermark using the VdoCipher WordPress video plugin annotation field and add_filter function in the functions file. shortcode embedded in WordPress.

Note: This phone number is a Custom Field created for illustration using a  plugin named “Advanced Custom Fields” and the name for this custom field is phone_number. You might not need to configure such custom fields, your membership plugin that you might be using would already have such custom field addition functionality. The phone number addition of a user on their profile needs to be managed and taken care of from your WordPress setup side. Your WordPress developers can check and implement it. For this example, the sample WordPress viewer playing the video has the phone number  887788778877 on his profile.

custom variables like phone number addition in wordpress user profile

custom field phone number addition via plugin

Below is a code demonstrating the usage of a sample function for displaying the saved phone number as a watermark and plugin setup.

Additions in functions.php WordPress file

  1. Login to your WordPress account having theme editor access.
  2. Open functions.php through Appearance>Theme File Editor or Tools>Theme File Editor
  3. Add given below custom PHP function in the functions.php file and save the file.
function customvdofunc($vdo_annotate_code){
   $Phonenumber = "";
   if (is_user_logged_in()) {
       $current_user = wp_get_current_user();
       $PNO = $current_user->phone_number;
          }
    $vdo_annotate_code = str_replace('{Phonenumber}', $PNO, $vdo_annotate_code);
    return $vdo_annotate_code;
}
add_filter('vdocipher_annotate_preprocess', 'customvdofunc');

Additions in functions php WordPress file

Adding JSON to the VdoCipher WordPress Plugin field

You need to add the following JSON code in the plugin settings to call the custom function and display the viewer’s phone number as a watermark.


[{"type":"rtext", "text":"{Phonenumber}", "alpha":"0.90","color":"#FFFF00","size":"12","interval":"5000","skip":5000}]

Adding JSON to the VdoCipher WordPress Plugin field

On playback of the videos, the watermark will show the phone number of the viewer playing the video. Similarly, you can call other custom or WordPress data fields via functions.php and display the same by adding more lines of JSON code in the VdoCipher plugin field.

watermark showing the phone number of the viewer playing the video

The post Custom variables as watermark on WordPress videos appeared first on VdoCipher Blog.

]]>
https://www.vdocipher.com/blog/custom-variables-watermark-on-wordpress-videos/feed/ 0