Affichage des articles dont le libellé est Automatically. Afficher tous les articles
Affichage des articles dont le libellé est Automatically. Afficher tous les articles

samedi 12 novembre 2016

How to Automatically Link Featured Images to Posts in WordPress



Recently one of our readers asked if it was possible to automatically link featured images to blog posts in WordPress. Most WordPress themes link featured images to posts by default, but some themes may not do that. In this article, we will show you how to automatically link featured images to posts in WordPress.


Automatically link featured images to posts in WordPress


Why Link Featured Images to Posts in WordPress?


Images are more engaging than text. Using featured images can boost user engagement on your site.


Usually, featured images are large and take more space than text. They are more colorful, hence more noticeable. They are also easier to click on smaller devices like mobile phones and tablets.


List25 using featured images to engage users


However, if your post thumbnails aren’t clickable, then it makes it harder for users to view your post.


Most WordPress themes link featured images to the posts by default. Some themes may not use that approach, which makes it difficult for you to properly utilize featured images.


Having said that, let’s see how you can automatically link featured images to posts in WordPress.


Automatically Link Featured Images to Posts in WordPress


This method required you to add code into your WordPress files. See our beginner’s guide on pasting snippets from web into WordPress.


Simply add this code to your theme’s functions.php file or a site-specific plugin.



function wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;
}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

This code simply adds a link around the code generated to display featured images or post thumbnails on your website.


This code will also add a link around featured images on single post pages. If you don’t want to link featured images on single post to the same post, then use this code.



function wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {

If (! is_singular()) {

$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;

} else {

return $html;

}

}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );


We hope this article helped you learn how to automatically link featured images to posts in WordPress. You may also want to see our list of 14 best featured image plugins and tutorials for WordPress.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Automatically Link Featured Images to Posts in WordPress appeared first on WPBeginner.







How to Automatically Add Watermark to Images in WordPress



Do you want to add watermark to your images in WordPress? Many photographers and artists use watermark to prevent misuse of their images. In this article, we will show you how to automatically add watermark to images in WordPress.


Watermark images in WordPress


Method 1: Adding Watermark to Images in WordPress Using Envira Gallery


Envira Gallery is the best WordPress gallery plugin in the market. It allows you to create beautiful and mobile friendly image galleries into your WordPress site.


Envira comes with a watermarking addon that makes it easy to add watermark to your WordPress images.


WPBeginner readers can use the Envira Gallery coupon code: WPB25 to get 25% Off on their purchase.


First thing you need to do is install and activate the Envira Gallery plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, you need to visit Envira Gallery » Settings page to enter your license key.


Envira Gallery license key


You can get this key from your account dashboard on Envira Gallery website.


After verifying your license key, you can head over to Envira Gallery » Addons page. Scroll down or search to locate the Watermarking Addon, and then install and activate it.


Watermarking addon


You are now ready to add your images into responsive galleries with watermark. Simply go to Envira Gallery » Add New to create your first image gallery.


Scroll down on the page and you will notice the watermarking tab. Clicking on it will show you settings for watermarking.


You need to click on the checkbox next to ‘Enabled’ to see more options.


Settings for watermarking addon in Envira Gallery


After that click on ‘Choose Watermark’ button and upload an image that you want to use as watermark. You can also change position and margin of the watermark image.


After adding a watermark image, you can now move on to adding images into this gallery. Scroll up, and then click on ‘Select files from computer’ or ‘Select files from other sources’ button.


Creating a new Envira Gallery


For detailed instructions, see our guide on how to easily create responsive WordPress image galleries with Envira.


After adding a few images to your gallery, you can publish it.


Now you can add this image gallery into any WordPress post or page. Simply edit a post or page and then click on the ‘Add Gallery’ button.


Add gallery to a post or page


Clicking on the button will bring up a popup where you need to select the image gallery you just created and then click on the insert button.


You will notice the Envira Gallery shortcode appear in the post editor. You can now save or publish your post/page.


Go ahead and visit your website to see the watermarked image gallery in action.


An image gallery in WordPress with watermarked images


Method 2: Adding Watermark to Images in WordPress Using Easy Watermark


First thing you need to do is install and activate the Easy Watermark plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, you need to go to Settings » Easy Watermark page to configure plugin settings.


Easy Watermark plugin settings


The settings page is divided into three tabs. The first option on the General settings tab is to automatically add watermark to all image uploads. You can also choose which image file types to auto watermark.


Next option is backup, you should check this if you want to save original uploads on your server too. You can also select which image sizes to add watermark to.


You also need to select watermark type. The plugin allows you to add text, image, or both to be used as watermark.


Review rest of the options on the page, and then click on save changes button to store your settings.


Now you can click on the Image tab on the plugin’s settings page. This is where you can upload the image you want to be used as watermark.


Upload watermark image


If you selected image+text or just the text as your watermark type, then you need to click on the text tab.


Here you can add the text you want to be displayed as watermark. You can select font, font size, watermark alignment, transparency, and color.


Watermark text


Don’t forget to click on the save changes button to store your settings.


You can now add watermark to images you add to your WordPress site.


Adding Watermark to Your Old Images in WordPress


To add watermark on the old images, you need to go to Media » Easy Watermark click on start button under Bulk Watermark section.


Add watermark to old images


Important: Please note that this process is irreversible. We strongly urge you to backup your WordPress site particularly your media uploads directory.


If you selected the option to keep a backup of your original uploads, then you can also use the restore option on this page, which will remove watermark from all images that have them.


Adding Watermark to Images Manually


In case you don’t want to automatically add watermark to all uploaded images, Easy Watermark gives you the manual option as well.


First thing you need to do is to go to Settings » Easy Watermark and make sure that the checkbox next to Automatically add watermark to images is unchecked.


After that you can go to Media » Library. You will need to switch to the list view to see the Add Watermark option next to each image in the library.


Manually add watermark


We hope this article helped you add you add watermark to images in WordPress. If you come across any issues, don’t forget to check our guide on common WordPress image issues and how to fix them.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Automatically Add Watermark to Images in WordPress appeared first on WPBeginner.