Hi,
regarding to this topic https://support.metabox.io/topic/taxonomy-image-on-custom-post-type/ I try to display in Image field of a custom term on the post display.
I try to make a shordcode like this:
function custom_shortcode() {
$terms = get_the_terms( get_queried_object_id(), 'language' );
foreach ( $terms as $term ) {
$term_image = rwmb_meta( 'term_flag', ['object_type' => 'term'], $term->term_id );
if( is_array( $term_image ) ) {
echo '<img src="'. $term_image['full_url'] .'">';
echo '<pre>'; // just for debugging
var_dump($term_image); // just for debugging
echo '</pre>'; // just for debugging
}
}
}
add_shortcode( 'termimage', 'custom_shortcode' );
I get an php warning:
Undefined array key "full_url"
This is the output of the var_dump:
array(1) {
[385]=>
array(15) {
["width"]=>
int(40)
["height"]=>
int(24)
["file"]=>
string(15) "2022/03/de1.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
string(1) "0"
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
string(1) "0"
["copyright"]=>
string(0) ""
["focal_length"]=>
string(1) "0"
["iso"]=>
string(1) "0"
["shutter_speed"]=>
string(1) "0"
["title"]=>
string(0) ""
["orientation"]=>
string(1) "0"
["keywords"]=>
array(0) {
}
}
["ID"]=>
string(3) "385"
["name"]=>
string(7) "de1.png"
["path"]=>
string(111) "/var/www/vhosts/t36updxb.web5.alfahosting-server.de/mylistingshowcase.online/wp-content/uploads/2022/03/de1.png"
["url"]=>
string(67) "https://mylistingshowcase.online/wp-content/uploads/2022/03/de1.png"
["full_url"]=>
string(67) "https://mylistingshowcase.online/wp-content/uploads/2022/03/de1.png"
["title"]=>
string(5) "de[1]"
["caption"]=>
string(0) ""
["description"]=>
string(0) ""
["alt"]=>
string(0) ""
["srcset"]=>
bool(false)
}
}
Can you please assist and tell me where is my mistake?
I'm a non professionell developer.
Thank you!