add alt images to profile images
This commit is contained in:
parent
669f4d5665
commit
5f88efda2c
5 changed files with 15 additions and 33 deletions
|
@ -1408,15 +1408,18 @@ function wasmo_get_user_image_url( $userid ) {
|
||||||
*/
|
*/
|
||||||
function wasmo_get_user_image( $userid ) {
|
function wasmo_get_user_image( $userid ) {
|
||||||
$userimg = get_field( 'photo', 'user_' . $userid );
|
$userimg = get_field( 'photo', 'user_' . $userid );
|
||||||
|
$user = get_userdata( $userid );
|
||||||
|
$alt = $user->display_name . ' profile image for wasmormon.org';
|
||||||
|
|
||||||
if ( $userimg ) {
|
if ( $userimg ) {
|
||||||
return wp_get_attachment_image( $userimg, 'medium' );
|
return wp_get_attachment_image( $userimg, 'medium', false, array(
|
||||||
} else {
|
'alt' => $alt
|
||||||
$user = get_userdata( $userid );
|
) );
|
||||||
|
} else {
|
||||||
$hash = md5( strtolower( trim( $user->user_email ) ) );
|
$hash = md5( strtolower( trim( $user->user_email ) ) );
|
||||||
$default_img = urlencode( 'https://raw.githubusercontent.com/circlecube/wasmo-theme/main/img/default.png' );
|
$default_img = urlencode( 'https://raw.githubusercontent.com/circlecube/wasmo-theme/main/img/default.png' );
|
||||||
$gravatar = $hash . '?s=300&d='.$default_img;
|
$gravatar = $hash . '?s=300&d='.$default_img;
|
||||||
return '<img src="https://www.gravatar.com/avatar/' . $gravatar . '" alt="' . $user->display_name . ' wasmormon.org profile image">';
|
return '<img src="https://www.gravatar.com/avatar/' . $gravatar . '" alt="' . $alt . '">';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Author: Evan Mullins
|
Author: Evan Mullins
|
||||||
Author URI: https://circlecube.com
|
Author URI: https://circlecube.com
|
||||||
Template: twentynineteen
|
Template: twentynineteen
|
||||||
Version: 1.12.2
|
Version: 1.12.3
|
||||||
License: GNU General Public License v2 or later
|
License: GNU General Public License v2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
Text Domain: wasmo
|
Text Domain: wasmo
|
||||||
|
|
|
@ -72,28 +72,15 @@ if ( false === ( $the_answers = get_transient( $transient_name ) ) ) {
|
||||||
'website' === $in_directory ||
|
'website' === $in_directory ||
|
||||||
( 'private' === $in_directory && is_user_logged_in() )
|
( 'private' === $in_directory && is_user_logged_in() )
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$userimg = get_field( 'photo', 'user_' . $userid );
|
|
||||||
$username = esc_html( $user->nickname );
|
$username = esc_html( $user->nickname );
|
||||||
|
|
||||||
$the_answers .= '<cite>';
|
$the_answers .= '<cite>';
|
||||||
$the_answers .= '<a class="person person-' . esc_attr( $userid ) . '" href="' . get_author_posts_url( $userid ) . '">';
|
$the_answers .= '<a class="person person-' . esc_attr( $userid ) . '" href="' . get_author_posts_url( $userid ) . '">';
|
||||||
$the_answers .= '<span class="directory-img">';
|
$the_answers .= '<span class="directory-img">';
|
||||||
|
$the_answers .= wasmo_get_user_image( $userid );
|
||||||
$userimg = get_field( 'photo', 'user_' . $userid );
|
|
||||||
if ( $userimg ) {
|
|
||||||
$the_answers .= wp_get_attachment_image( $userimg, 'thumbnail' );
|
|
||||||
} else {
|
|
||||||
$hash = md5( strtolower( trim( $user->user_email ) ) );
|
|
||||||
$default_img = urlencode( 'https://raw.githubusercontent.com/circlecube/wasmo-theme/main/img/default.png' );
|
|
||||||
$gravatar = $hash . '?s=150&d='.$default_img;
|
|
||||||
$the_answers .= '<img src="https://www.gravatar.com/avatar/' . $gravatar . '">';
|
|
||||||
}
|
|
||||||
$the_answers .= '</span>';
|
$the_answers .= '</span>';
|
||||||
$the_answers .= '<span class="directory-name">' . $username . '</span>';
|
$the_answers .= '<span class="directory-name">' . $username . '</span>';
|
||||||
$the_answers .= '</a>';
|
$the_answers .= '</a>';
|
||||||
$the_answers .= '</cite>';
|
$the_answers .= '</cite>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$the_answers .= '</div>';
|
$the_answers .= '</div>';
|
||||||
|
|
|
@ -35,28 +35,28 @@ $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('a
|
||||||
<?php if ( $links['facebook'] ) {
|
<?php if ( $links['facebook'] ) {
|
||||||
$svg = twentynineteen_get_social_link_svg( $links['facebook'], 26 );
|
$svg = twentynineteen_get_social_link_svg( $links['facebook'], 26 );
|
||||||
?>
|
?>
|
||||||
<li class="facebook"><a target="_blank" rel="noopener noreferrer" href="<?php
|
<li class="facebook"><a target="_blank" rel="nofollow ugc noopener noreferrer" href="<?php
|
||||||
echo esc_url( $links['facebook'] );
|
echo esc_url( $links['facebook'] );
|
||||||
?>"><span class="screen-reader-text">Facebook</span><?php echo $svg; ?></a></li>
|
?>"><span class="screen-reader-text">Facebook</span><?php echo $svg; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ( $links['instagram'] ) {
|
<?php if ( $links['instagram'] ) {
|
||||||
$svg = twentynineteen_get_social_link_svg( $links['instagram'], 26 );
|
$svg = twentynineteen_get_social_link_svg( $links['instagram'], 26 );
|
||||||
?>
|
?>
|
||||||
<li class="instagram"><a target="_blank" rel="noopener noreferrer" href="<?php
|
<li class="instagram"><a target="_blank" rel="nofollow ugc noopener noreferrer" href="<?php
|
||||||
echo esc_url( $links['instagram'] );
|
echo esc_url( $links['instagram'] );
|
||||||
?>"><span class="screen-reader-text">instagram</span><?php echo $svg; ?></a></li>
|
?>"><span class="screen-reader-text">instagram</span><?php echo $svg; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ( $links['reddit'] ) {
|
<?php if ( $links['reddit'] ) {
|
||||||
$svg = twentynineteen_get_social_link_svg( $links['reddit'], 26 );
|
$svg = twentynineteen_get_social_link_svg( $links['reddit'], 26 );
|
||||||
?>
|
?>
|
||||||
<li class="reddit"><a target="_blank" rel="noopener noreferrer" href="<?php
|
<li class="reddit"><a target="_blank" rel="nofollow ugc noopener noreferrer" href="<?php
|
||||||
echo esc_url( $links['reddit'] );
|
echo esc_url( $links['reddit'] );
|
||||||
?>"><span class="screen-reader-text">reddit</span><?php echo $svg; ?></a></li>
|
?>"><span class="screen-reader-text">reddit</span><?php echo $svg; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ( $links['twitter'] ) {
|
<?php if ( $links['twitter'] ) {
|
||||||
$svg = twentynineteen_get_social_link_svg( $links['twitter'], 26 );
|
$svg = twentynineteen_get_social_link_svg( $links['twitter'], 26 );
|
||||||
?>
|
?>
|
||||||
<li class="twitter"><a target="_blank" rel="noopener noreferrer" href="<?php
|
<li class="twitter"><a target="_blank" rel="nofollow ugc noopener noreferrer" href="<?php
|
||||||
echo esc_url( $links['twitter'] );
|
echo esc_url( $links['twitter'] );
|
||||||
?>"><span class="screen-reader-text">twitter</span><?php echo $svg; ?></a></li>
|
?>"><span class="screen-reader-text">twitter</span><?php echo $svg; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
@ -66,7 +66,7 @@ $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('a
|
||||||
$svg = wasmo_get_icon_svg( 'link' );
|
$svg = wasmo_get_icon_svg( 'link' );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<li class="other"><a target="_blank" rel="noopener noreferrer" href="<?php
|
<li class="other"><a target="_blank" rel="ugc noopener noreferrer" href="<?php
|
||||||
echo esc_url( $links['other'] );
|
echo esc_url( $links['other'] );
|
||||||
?>"><span class="screen-reader-text">other</span><?php echo $svg; ?></a></li>
|
?>"><span class="screen-reader-text">other</span><?php echo $svg; ?></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -57,23 +57,15 @@ get_header();
|
||||||
'website' === $in_directory ||
|
'website' === $in_directory ||
|
||||||
( 'private' === $in_directory && is_user_logged_in() )
|
( 'private' === $in_directory && is_user_logged_in() )
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$userimg = get_field( 'photo', 'user_' . $userid );
|
|
||||||
$username = esc_html( $user->nickname );
|
$username = esc_html( $user->nickname );
|
||||||
|
|
||||||
$the_answers .= '<cite>';
|
$the_answers .= '<cite>';
|
||||||
$the_answers .= '<a class="person person-' . esc_attr( $userid ) . '" href="' . get_author_posts_url( $userid ) . '">';
|
$the_answers .= '<a class="person person-' . esc_attr( $userid ) . '" href="' . get_author_posts_url( $userid ) . '">';
|
||||||
$the_answers .= '<span class="directory-img">';
|
$the_answers .= '<span class="directory-img">';
|
||||||
if ( $userimg ) {
|
$the_answers .= wasmo_get_user_image( $userid );
|
||||||
$the_answers .= wp_get_attachment_image( $userimg, 'medium' );
|
|
||||||
} else {
|
|
||||||
$the_answers .= '<img src="' . get_stylesheet_directory_uri() . '/img/default.svg">';
|
|
||||||
}
|
|
||||||
$the_answers .= '</span>';
|
$the_answers .= '</span>';
|
||||||
$the_answers .= '<span class="directory-name">' . $username . '</span>';
|
$the_answers .= '<span class="directory-name">' . $username . '</span>';
|
||||||
$the_answers .= '</a>';
|
$the_answers .= '</a>';
|
||||||
$the_answers .= '</cite>';
|
$the_answers .= '</cite>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$the_answers .= '</div>';
|
$the_answers .= '</div>';
|
||||||
|
|
Loading…
Reference in a new issue