Image Advanced
- This topic has 5 replies, 2 voices, and was last updated 9 years, 1 month ago by
sergeysemenov.
-
AuthorPosts
-
March 18, 2016 at 4:22 PM #2521
sergeysemenov
ParticipantHi!
<?php $group_value = rwmb_meta( 'rw_mygroup' ); foreach ( $group_value as $group_value ) { echo '<div> <div class="image"><img src="' . $group_value['rw_img'] . '" /></div> <div>' . $group_value['rw_textfield1'] . '</div> <div>' . $group_value['rw_textfield2'] . '</div> <div>' . $group_value['rw_textfield3'] . '</div></div>'; } ?>
Everything works great with file_input, but not retrieve img with image_advanced. Could you please provide the php code to call image_advanced attachment in the template.
March 18, 2016 at 4:37 PM #2522sergeysemenov
Participant<?php $group_value = rwmb_meta( ‘rw_mygroup’ ); foreach ( $group_value as $group_value ) { echo ‘<div> <div class=”image”><img src="' . $group_value['rw_img'] . '"></div> <div>’ . $group_value[‘rw_textfield1’] . ‘</div> <div>’ . $group_value[‘rw_textfield2’] . ‘</div> <div>’ . $group_value[‘rw_textfield3’] . ‘</div></div>’; } ?>
Everything works great with file_input, but not retrieve img with image_advanced. Could you please provide the php code to call image_advanced attachment in the template.
March 21, 2016 at 1:44 PM #2537Anh Tran
KeymasterHi Sergey Semenov,
The value stored by
image_advanced
is attachment ID, so when you get them, you will receive an array of integers. (The helper function doesn't work pretty well for group at the moment and I will fix it soon so it can return more info of the image instead of just ID).In the meantime, please try this code:
<?php $group_value = rwmb_meta( 'rw_mygroup' ); foreach ( $group_value as $group_value ) { echo '<div> <div class="image"><img src="' . wp_get_attachment_image_url( $group_value['rw_img'], 'thumbnail' ) . '" /></div> <div>' . $group_value['rw_textfield1'] . '</div> <div>' . $group_value['rw_textfield2'] . '</div> <div>' . $group_value['rw_textfield3'] . '</div> </div>'; } ?>
You can change the code to use different image size if you want.
March 24, 2016 at 6:10 PM #2565sergeysemenov
ParticipantThanks for assistance, Anh Tran. Provided code doesn't get attached image. Still looking for your help.
March 25, 2016 at 10:39 AM #2576Anh Tran
KeymasterSorry, here is the correct one:
$group_values = rwmb_meta( 'rw_mygroup' ); foreach ( $group_values as $group_value ) { echo '<div> <div class="image"><img src="' . wp_get_attachment_image_url( reset( $group_value['rw_img'] ), 'thumbnail' ) . '" /></div> <div>' . $group_value['rw_textfield1'] . '</div> <div>' . $group_value['rw_textfield2'] . '</div> <div>' . $group_value['rw_textfield3'] . '</div> </div>'; }
March 25, 2016 at 6:57 PM #2585sergeysemenov
ParticipantThank you, Anh Tran. That works.
Good product, good support.
Topic closed. -
AuthorPosts
- The topic ‘Image Advanced’ is closed to new replies.