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

samedi 12 novembre 2016

How to Change the Gravatar Image Size in WordPress



Recently one of our readers asked if it is possible to change the Gravatar image size. The answer is yes. In this article, we will show you how to change the Gravatar image size in WordPress.


How to Change Gravatar Image Size in WordPress


Gravatar is a globally recognized avatar that connects a user’s email address with their picture. Popular applications like WordPress and others use it to display user’s photo on the website.


Most WordPress themes by default add a Gravatar next to each user comment. Some even use it for the author bio box.


Let’s take a look at how you can change the Gravatar image size on your WordPress site.


Note: Since Gravatar Image size is defined by your theme, you would need to edit your theme files to change it.


Change Gravatar size for WordPress Comments


The first thing you need to do is open the comments.php file located in your themes folder.


You would need to connect to your website using FTP and then go to /wp-content/themes/yourtheme/.


Alternatively if your WordPress hosting company offers a File Manager, then you can edit this file using the web interface in your cPanel.


In the comments.php file, you need to find the following code: avatar_size


It will be inside the wp_list_comments function like this:



<?php
wp_list_comments( array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 32,
) );
?>

Simply change the size to whatever dimensions you like. Gravatars are square, so the value you set will be the same for both width and height.


Go ahead and save your changes. If you are using FTP, then upload the changes to your server.


Now open a post that has comments to see if your changes are live.


If it is not, then your theme’s CSS is overriding it. The best way to check is to use Inspect Elements tool in your browser.


Simply right click on the Gravatar in your browser and click Inspect Element.


Inspect Element Comments Gravatar


You need to look at the height and width of the Gravatar image to see if it reflects the value that you set.


When you bring your mouse over it, it will also highlight the gravatar on the image and show you the size it’s actually displaying.


Gravatar Image Size WordPress


You’ll notice that the two are different. This means that your theme’s style.css file is overriding the default image size. Many themes including the default Twenty Sixteen theme use CSS to control the Gravatar image size for different screen sizes.


You need to open the style.css file in your theme’s folder and search for avatar. You’ll likely find a CSS class: .comment-author .avatar which contain a code like this:



.comment-author .avatar {
height: 42px;
position: relative;
top: 0.25em;
width: 42px;
}

Go ahead and change the width and height to match the value you set earlier in the comments.php file.


That’s all. You have successfully changed the gravatar image size in your WordPress comments.


Now you might be wondering if you can override the image size using CSS, then why did we change the avatar_size in the comments.php file?


Yes, while you can take the CSS shortcut, there are two benefits to doing it this way:


1. No blurry images


If you wanted to resize the WordPress Gravatar and make it larger then the default image size, then it will look blurry.


2. Faster Load Times


Now if you wanted to make the Gravatar smaller then the default image size, then the CSS only method will look just fine.


However by changing the size in comments.php, you’re actual image is smaller thus reducing the page size and improving your site speed.


Change Gravatar size for Author Bio


Depending on the theme that you use, it may also use Gravatar for author bio boxes. You can change the default gravatar size in a very similar way as comments.


You need to locate the theme file which adds the bio. It could be in the single.php file, functions.php file, or even as a separate template part file. The default Twenty Sixteen theme uses the template part file called biography.php.


When searching the files, you need to look for the code get_avatar.


For the sake of this example, we will use TwentySixteen default theme as an example. In the themes folder:


/wp-content/themes/twentysixteen/template-parts/biography.php file


It reads like this:



$author_bio_avatar_size = apply_filters( 'twentysixteen_author_bio_avatar_size', 32 );

echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );

You will just have to change the number 32 to whatever you like.


In other themes, the code may look like this:



get_avatar( get_the_author_meta( 'user_email' ), 32);

After you change the size, refresh the page to see if the size updated. If not, then you’d need to search for the avatar class in the style.css file like we showed for comments, and update the size there as well.


We hope this article helped you change the gravatar size in WordPress. You may also want to see our guide on 25 most common WordPress errors 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 Change the Gravatar Image Size in WordPress appeared first on WPBeginner.


Page 7 – WPBeginner




How to create link with hover image in plain CSS



alt="How to create link with hover image in plain CSS" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2009/10/hover-css-skill-500x312_c.jpg" />

style="line-height: 1.5em;">What’s a hover?style="line-height: 1.5em;"> style="line-height: 1.5em;">Definition quoted from style="line-height: 1.5em;" href="http://www.uwstout.edu/soe/profdev/advwebdesign/two/glossary.html">UWStout.edustyle="line-height: 1.5em;">:

‘Hover’ is an effect that occurs when you place the cursor over a link of any kind. The link can be coded to respond to the hover by changing color, showing a new graphic, or even playing a sound file.

The hover effect improves web usability and helps web owners to direct their web traffics. When you wish your web users to pay extra attention to a special link, a good way to do so is to create a link with attractive hover effect. A simple hover effect href="#">like this (a simple underline and change of text color) indicates those text are ‘click-able’ and improves web interactions. However, changing text color and styles (underline/overline/bold) is very basics and there are a lot more can be done with hover.

In this article, I’m going to show how you can create good looking links with hover effect.

Example 1: Link with hover button

First, a look at the working example (place mouse over the link to see how it works – change of icon at the side).

class="x">href="#">Example 1 – Link with hover button image

This is the completed version of what will be built in this example.

How we create it in plain CSS?

The Button Image

Step 1, as you can see, we need a arrow icons in two different versions. In our example, I used red (#CC3300) as the default link button; and grey (#333333) for the hover effect. Such button can be easily made using any image editing software.

We now have the red color button (say, b1.png) and the rey color (button say, b2.png). Merge these two into one image file with b1.png on top of b2.png. This will be our final image for the link. Name it (say, x.png) and upload the desired location (for my case, I placed it in my WP template folder).

For your reference:

b1.png alt="" src="http://www.webhostingsecretrevealed.net/images/2009/1020-1.jpg" /> , b2.png alt="" src="http://www.webhostingsecretrevealed.net/images/2009/1020-2.jpg" /> , and x.png alt="" src="http://www.webhostingsecretrevealed.net/images/2009/1020-3.jpg" />

The CSS Code

Next, on the CSS code. Basically what we want to achieve is to indent the link text slightly to the right to make space for the button; and in the same time, display a different image when the link is in hover state. These are pretty fundamental stuffs except that we need a little twist on the background position. The trick is to show the top part of the image (the red button) for the original link; and when hover, displace the background image with a -11px (it might differs on your website) margin to show the grey button.

.x a {
color: #cc3300;
padding-left: 14px;
font-weight: bold;
background-image: url(images/x.png);
background-position: 0 2px;
background-repeat: no-repeat;
}
.x a:hover {
color: #333333;
padding-left: 14px;
font-weight: bold;
background-image: url(images/x.png);
background-position: 0 -11px;
background-repeat: no-repeat;
}

Implementation

To show off this hover effect, simply insert class x into the designated area. Here’s an example on how you can do it.

<p class='x'><a href="http://www.webhostingsecretrevealed.com">Homepage</a></p>

Example 2: Link in hover background

With the same concept, there are endless ways you can make your links look cool. Here’s another example on what we can do with the hover effects with a slightly different method. Again, have a look on the finished version.

class="y" href="#">Example 2 – Link in hover background

In this example, what I will do is to create a button-liked hyperlink where the background will change when users place their mouse over it.

How we create it in plain CSS?

The background images

First, create two images of rounded rectangle. For demonstration purpose, we will not merge these two images in this example. We’ll name the red (#CC3300) rectangle as b1.png; and the maroon (#9F2800) rectangle as b2.png.

alt="" src="http://www.webhostingsecretrevealed.net/images/home/b1.png" />

alt="" src="http://www.webhostingsecretrevealed.net/images/home/b2.png" />

The CSS Code

Next, here are the codes for your style sheet (we are naming the class ‘y’ in this second example).

a.y {
width: 280px;
height: 42px;
color: #000000;
padding: 10px;
text-decoration:none;
display: block;
font-weight: bold;
background-image : url(images/b1.png);
background-repeat: no-repeat;
}
a.y:hover {
width: 280px;
height: 42px;
color: #FFFFFF;
padding: 10px;
font-weight: bold;
text-decoration:none;
display: block;
background-image : url(images/b2.png);
background-repeat: no-repeat;
}

Implementation

To display the link, simple insert the class (y) into the <a href> tag in your source code. Example:

<a href="http://www.webhostingsecretrevealed.com" class="y" >Homepage</a>

Wrapping up

I hope this article brought you valuable information and inspired some of you to use CSS in an creative way. If there’s any other points you think I should add in this guide, feel free to leave your ideas in the comment section.

More CSS tutorials

If you like this post, be sure to also check outhref="http://www.webhostingsecretrevealed.net/blog/web-design/30-latest-css3-tutorials-you-probably-have-not-read-before/"> How to make good use of  CSS 3 animations, href="http://www.webhostingsecretrevealed.net/blog/web-design/30-latest-css3-tutorials-you-probably-have-not-read-before/">Must Read CSS 3 Tutorials 2012, as well as href="http://www.webhostingsecretrevealed.net/blog/featured-articles/make-your-webite-beautiful-20-must-read-css3-tutorials/">Make your site cool with these CSS 3 techniques.


Page 30 – Web Hosting Secret Revealed