Display Image advaced
- This topic has 1 reply, 2 voices, and was last updated 4 years, 9 months ago by
Long Nguyen.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 13, 2020 at 5:16 AM #20742
SaraKay
ParticipantHello,
Could you please help me displaying the uploaded image in a group:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = array ( 'title' => esc_html__( 'Podcast', 'text-domain' ), 'id' => 'podcast', 'post_types' => array( 0 => 'post', ), 'context' => 'normal', 'priority' => 'high', 'fields' => array( array ( 'id' => $prefix . 'podcast_number', 'type' => 'text', 'name' => esc_html__( 'Episode Number', 'text-domain' ), 'required' => 1, 'columns' => 2, ), array ( 'id' => $prefix . 'podcast_author', 'type' => 'text', 'name' => esc_html__( 'Podcast Author/authors', 'text-domain' ), 'required' => 1, 'columns' => 3, ), array ( 'id' => $prefix . 'podcast_title', 'type' => 'textarea', 'name' => esc_html__( 'Podcast Title', 'text-domain' ), 'rows' => 1, 'cols' => 2, 'required' => 1, 'columns' => 7, ), array ( 'id' => $prefix . 'podcast_about', 'name' => esc_html__( 'About podcast', 'text-domain' ), 'type' => 'wysiwyg', ), array ( 'id' => $prefix . 'left_links_2', 'name' => esc_html__( 'Links mentioned (left Column)', 'text-domain' ), 'type' => 'wysiwyg', 'columns' => 6, ), array ( 'id' => $prefix . 'right_links_2', 'name' => esc_html__( 'Links mentioned (right Column)', 'text-domain' ), 'type' => 'wysiwyg', 'columns' => 6, ), array ( 'id' => $prefix . 'author_image', 'type' => 'image_upload', 'name' => esc_html__( 'Author image', 'text-domain' ), 'max_status' => 1, 'max_file_uploads' => 1, 'image_size' => 'medium', ), ), ); return $meta_boxes; }
I need to add a shortcode for it. I've tried the code bellow but it won't work:
$images = rwmb_meta( 'author_image', array( 'limit' => 1 ) );
$image = reset( $images );
?>
">
Thanks
July 13, 2020 at 10:40 AM #20746Long Nguyen
ModeratorHi,
The code to show the image on the post works as well.
$images = rwmb_meta( 'author_image', array( 'limit' => 1 ) ); $image = reset( $images ); ?> <img src="<?php echo $image['url']; ?>">
See more in my screen record https://www.loom.com/share/8f6d40a956524aca83c970fd169c6e5f. If you are using the field
image_upload
as a subfield of a group, please follow this documentation to get the field value https://docs.metabox.io/extensions/meta-box-group/#sub-field-values. -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.