Skip to content

Commit

Permalink
Merge pull request #1208 from vektor-inc/fix/profile-image-warning
Browse files Browse the repository at this point in the history
[ G3 ][ Bug fix ] Fix profile image warning
  • Loading branch information
kurudrive authored Dec 7, 2024
2 parents a6008a4 + 3e428a5 commit ee721ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions _g3/inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,24 @@ function lightning_get_entry_meta( $options = array() ) {
<span class="vcard author" itemprop="author">';

if ( $option['author_image'] ) {
$html .= '<span class="entry-meta-item-author-image">';

// VK Post Author Display の画像を取得.
$profile_image_id = get_the_author_meta( 'user_profile_image' );
if ( $profile_image_id ) {
$profile_image_src = wp_get_attachment_image_src( $profile_image_id, 'thumbnail' );
$html .= '<img src="' . $profile_image_src[0] . '" alt="' . esc_attr( $author ) . '" />';
$vk_post_author_display_image_src = wp_get_attachment_image_src( $profile_image_id, 'thumbnail' );
}
// 画像がメディアライブラリ側で削除されたりもするため、 is_array で判定.
if ( isset( $vk_post_author_display_image_src ) && is_array( $vk_post_author_display_image_src ) ) {
$profile_image = '<img src="' . $vk_post_author_display_image_src[0] . '" alt="' . esc_attr( $author ) . '" />';
} else {
$html .= get_avatar( get_the_author_meta( 'email' ), 30 );
// プロフィール画像がない場合は Gravatar.
$profile_image = get_avatar( get_the_author_meta( 'email' ), 30 );
}

$html .= '</span>';
if ( $profile_image ) {
$html .= '<span class="entry-meta-item-author-image">';
$html .= $profile_image;
$html .= '</span>';
}
}

if ( $option['author_name'] ) {
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ https://www.vektor-inc.co.jp/inquiry/

== Changelog ==

[ G3 ][ Bug fix ] Fix profile image warning
[ G2 ][ Specification Change ] Change load module priority

v15.28.2
Expand Down

0 comments on commit ee721ca

Please sign in to comment.