Affichage des articles dont le libellé est Size. Afficher tous les articles
Affichage des articles dont le libellé est Size. 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




7 Tips To Reduce WordPress Database Size



alt="7 Tips To Reduce WordPress Database Size" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/database-500x225_c.jpg" />

Serious about speeding up your WordPress-hosted website?

Then you’ve likely shelled out money for a clutter-free design or codes that reduce the loading time of your site.

And if you’re anything like the typical webmaster, you eagerly devour the worksheets, ebooks and webinars that teach you to increase site speed.

But it turns out, you may not need to pony up some dough.

Why, you ask?

Because reducing the size of your WordPress database can significantly reduce your site’s loading time and improve its speed.

It’s no secret that search engines give a lot of href="http://www.searchenginejournal.com/faster-wordpress-need-speed/113155/" target="_blank">importance to site speed, and that your website loading time can affect your search rankings in a small percentage. This does not specifically mean a faster website will boost your ranking, but it assists crawlers to access your web pages easily and provide a better user experience to visitors.

And the larger your WordPress database is, the more time it could take to render pages for those visiting your website. So it’s essential for you to href="http://www.webhostingsecretrevealed.net/blog/wordpress-blog/wordpress-performance-optimization-data-comes-before-optimization/" target="_blank">cleanup your WordPress database and reduce its size. Over time, your database may have unused records, redundant entries and tables which you can safely remove without affecting other elements of your site. This will assist in removing the load time on your server and improve the performance of your site.

Curious about how to reduce the size of your WordPress database? What follows are seven steps to reduce WordPress database size that can be put into practice instantly:

1. Delete unwanted plugins

class="alignright wp-image-10706 size-medium" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/1-300x234.png" alt="1" width="300" height="234" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/1-300x234.png 300w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/1.png 396w" sizes="(max-width: 300px) 100vw, 300px" />

Did you know there are over 20,000 WordPress plugins? The ease with which you can install a plugin is a blessing and a curse at the same time. Your database will always suffer from plugin bloat, as each plugin, even when deactivated, adds more code for WordPress to load.

So do your database, and your site, a favor, and delete all those plugins you haven’t used in a while. This can be done easily through the plugin section in your WordPress dashboard.

2. Delete spam comments and unwanted codes

class="alignright wp-image-10707" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/2.png" alt="2" width="300" height="210" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/2.png 750w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/2-300x210.png 300w" sizes="(max-width: 300px) 100vw, 300px" />

There should be comments and posts in your spam and trash folder: this is the unnecessary clutter you need to remove. You should also delete any post revisions that were left as drafts and new posts were published instead.

You can use the href="https://wordpress.org/plugins/wp-optimize/" target="_blank">WP-optimize plugin to get the job done with a single click. At the same time, you can use Clean Options for WordPress plugin to find unused tables in your database and clean them as well.

3. Use MySQL queries

Akismet plugin increases the database size in many instances due to the table called wp_commentmeta. Install the href="https://wordpress.org/plugins/wp-dbmanager/" target="_blank">WP db manager plugin > run the following two query options – they can be executed from the WordPress dashboard (but run each of them separately):

DELETE FROM wp_commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
DELETE FROM wp_commentmeta WHERE meta_key LIKE ‘%akismet%’;

Your WordPress installation might be a bit different, so don’t forget to check your table name before applying the queries above. The following SQL queries are also helpful in reducing database size:

DELETE FROM wp_postmeta WHERE meta_key = "_edit_lock";
DELETE FROM wp_postmeta WHERE meta_key = "_edit_last";

4. Compress images

class="alignright wp-image-10709 size-medium" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/4-300x170.png" alt="4" width="300" height="170" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/4-300x170.png 300w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/09/4.png 724w" sizes="(max-width: 300px) 100vw, 300px" />

Compressing your images can greatly reduce the amount of data residing in your database. You can use gzip compression to reduce the size of text based resources such as CSS, JavaScript and HTML.

You can also use the href="https://wordpress.org/plugins/wp-smushit/" target="_blank">WP Smush.it plugin that will compress images when you upload new ones to the media library by stripping meta data from JPEGs, converting GIFs to indexed PNGs, stripping the unused colors from indexed images, and optimizing JPEG compression. WP Smush.it will run quietly behind the scenes.

5. Turn off Autosave

WordPress saves the changes you make to posts every 2 minutes and stores them as revision. All the revisions of a single post are saved as separate entries in the database, which makes the database drastically large.

If you’re writing long posts, turning off the autosave feature is viable solution. Add the following code to your functions.php file between the closing and opening php tags:

function disableAutoSaveCompletely() {
wp_deregister_script('autosave');
}
add_action( 'wp_print_scripts', 'disableAutoSaveCompletely' );

6. Optimize WordPress database

The database is the place where everything is stored: comments, settings, pages, posts, plugins and codes. A bloated database means every time a page is reloaded, it can take longer for the information to be found and displayed.

This is why you need to optimize your database. Using href="https://wordpress.org/plugins/wp-dbmanager/" target="_blank">WP-DB manager or href="https://wordpress.org/plugins/wp-optimize/" target="_blank">WP optimize plugin is a great way to restore, repair, optimize and backup your database.

7. Use cache plugins

Caching plugins such as href="https://wordpress.org/plugins/w3-total-cache/" target="_blank">W3 Total Cache create a static version of your pages for first time visitors. So the database is accessed to generate your page when someone visits it for the first time.

With a cache plugin, the generated page is stored on the server, so when a user visits a page for the next time, the same page is pre-generated and the database isn’t called in.

Take the following measures to optimize your WordPress database. You’ll notice instant results.


Page 12 – Web Hosting Secret Revealed