Skip to content

Commit

Permalink
image meta formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tim0haapala committed Dec 14, 2021
1 parent a3280f9 commit ff5dddb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions lib/Formatters/ImageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion partials/ui/image/image-block__meta.dust
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="columns image-block__meta pt-2{?author_name} is-reversed{/author_name}">
{?author_name}
<div class="column is-2 has-text-right image-block__author-name has-text-small">
{author_name|s}
{author_name|s}.
</div>
{/author_name}
{?caption}
Expand Down

0 comments on commit ff5dddb

Please sign in to comment.