From ff5dddb07fb906de2f3d90130c2ef3001284edef Mon Sep 17 00:00:00 2001 From: Timo Haapala Date: Tue, 14 Dec 2021 16:42:27 +0200 Subject: [PATCH] image meta formatting --- lib/Formatters/ImageFormatter.php | 19 +++++++------------ partials/ui/image/image-block__meta.dust | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/Formatters/ImageFormatter.php b/lib/Formatters/ImageFormatter.php index 0c2b1166..707463dd 100644 --- a/lib/Formatters/ImageFormatter.php +++ b/lib/Formatters/ImageFormatter.php @@ -95,20 +95,15 @@ public static function get_image_artist( array $row, array $image ) : array { $row['artist_name'] = trim( get_field( 'artist_name', $image_id ) ); $row['image_title'] = trim( $image['title'] ?? '' ); - if ( ! empty( $row['artist_name'] ) && ! empty( $row['image_title'] ) ) { - $row['image_title_and_artist'] = sprintf( - '%s: %s', - $row['artist_name'], - $row['image_title'] - ); + if ( ! empty( $row['artist_name'] ) ) { + $row['image_title_and_artist'] .= sprintf( '%s: ', $row['artist_name'] ); + } + elseif ( ! empty( $row['author_name'] ) ) { + $row['image_title_and_artist'] .= sprintf( '%s: ', $row['author_name'] ); } - if ( ! empty( $row['author_name'] ) && ! empty( $row['image_title'] ) ) { - $row['image_author_and_artist'] = sprintf( - '%s: %s', - $row['author_name'], - $row['image_title'] - ); + if ( ! empty( $row['image_title'] ) ) { + $row['image_title_and_artist'] .= sprintf( '%s.', $row['image_title'] ); } return $row; diff --git a/partials/ui/image/image-block__meta.dust b/partials/ui/image/image-block__meta.dust index 3a0eb36b..546af3db 100644 --- a/partials/ui/image/image-block__meta.dust +++ b/partials/ui/image/image-block__meta.dust @@ -1,7 +1,7 @@
{?author_name}
- {author_name|s} + {author_name|s}.
{/author_name} {?caption}