File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Fixed
11
+
12
+ - PIEN-8524: Display API image #152
13
+
10
14
## [ 1.8.0] - 2023-04-11
11
15
12
16
- PIEN-8157: PHP 8.1
Original file line number Diff line number Diff line change @@ -89,15 +89,18 @@ public function related() : ?array {
89
89
? wp_get_post_terms ( $ item ->ID , Category::SLUG )
90
90
: [];
91
91
92
+ $ item ->api_image_url = get_field ( 'image_url ' , $ item ->ID );
93
+ $ has_image = $ item ->image_id !== 0 || ! empty ( $ item ->api_image_url );
94
+
95
+ if ( ! $ has_image ) {
96
+ $ item ->image_id = Images::get_default_image_id ();
97
+ }
98
+
92
99
if ( ! empty ( $ categories ) ) {
93
100
$ item ->category = $ categories [0 ]->name ;
94
101
$ item ->category_link = get_category_link ( $ categories [0 ]->ID );
95
102
}
96
103
97
- $ item ->image_id = $ item ->image_id === 0
98
- ? Images::get_default_image_id ()
99
- : $ item ->image_id ;
100
-
101
104
if ( ! has_excerpt ( $ item ->ID ) ) {
102
105
$ item ->post_excerpt = $ this ->get_related_excerpt ( $ item );
103
106
}
Original file line number Diff line number Diff line change 14
14
{#related.posts}
15
15
<div class="column is-6 is-3-widescreen">
16
16
<div class="related-posts__item mb-4 mb-0-tablet">
17
- {?image_id }
17
+ {?api_image_url }
18
18
<div class="image is-4by3">
19
19
<a href="{permalink|url}" aria-hidden="true" tabindex="-1">
20
- {@image id=image_id size="large " class="objectfit-image" /}
20
+ <img src="{api_image_url|url} " class="objectfit-image" loading="lazy" alt=""/>
21
21
</a>
22
22
</div>
23
- {/image_id}
23
+ {:else}
24
+ {?image_id}
25
+ <div class="image is-4by3">
26
+ <a href="{permalink|url}" aria-hidden="true" tabindex="-1">
27
+ {@image id=image_id size="large" class="objectfit-image" /}
28
+ </a>
29
+ </div>
30
+ {/image_id}
31
+ {/api_image_url}
24
32
25
33
{?post_title}
26
34
<h3 class="h4 mt-5 mb-5">
You can’t perform that action at this time.
0 commit comments