Support Forum
Support › Meta Box Group › Image Advanced
Hi!
<?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.
<?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.
Hi 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.
Thanks for assistance, Anh Tran. Provided code doesn't get attached image. Still looking for your help.
Sorry, 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>';
}
Thank you, Anh Tran. That works.
Good product, good support.
Topic closed.