How to convert the avatar image set in Simple Local Avatar to SSL

by Tomoe Onishi
This time, the site operated by Sakura rental server, WordPress has been converted into SSL.

Image URL replacement and redirect can be easily performed with Sakura's constantly SSL plug -in SAKURA RS WP SSL.

How to use the SSL conversion plugin [SAKURA RS WP SSL] When SSL is well converted, it is displayed as a protected communication to the left of the URL bar,https: //The part becomes green, but if there is a mixed content, the part of the https: // will not turn green and will be warned.

CHROME Browser Developer Tool Console(In the case of Windows, F12 key, Mac is Command + Option + I key)When I checked, there were some image files starting with http: //, which were not converted to SSL.

Images with direct image URLs such as widgets and logo are not automatically replaced by the plug -in, so if they are re -uploaded, it will be https: //.

Some re -uploaded and became https: //, but this time the warning of the mixed content has not disappeared yet.

If you check it in Console, the target file isAvatar image (profile image, contributor thumbnail image)So, despite the re -uploaded, it remains http: //.

The cause was Simple Local Avatars of the avatar setting plugin

There are three ways to set an avatar in WordPress.

・ Use plug -in
・ Use Gravatar
・ Add code to .htaccsess to register an avatar on this site"Simple Local Avatars"The avatar is displayed using.

If you have the authority of the administrator, you can upload the image from the setting screen, but even if you upload it again, it will remain http: //.

Therefore, the following code to convert an avatar into SSL at the bottom of functions.php is added.
function ssl_simple_local_avatar( $avatar ) {
    $ avatar = str_replace ('http:', '', $ avatar);
    Return $ Avatar;
}
Add_filter ('simple_local_avatar', 'ssl_simple_local_avatar');
The avatar image was safely https: //, and the warning of the mixed content disappeared and the green was displayed.
この著者の記事一覧

One -stop offered from EC construction to advertising operation.

WHITEPAPER DOWNLOAD inquiry