• Creator
    Topic
  • #2521
    sergeysemenov
    Participant

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #2522
    sergeysemenov
    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.

    #2537
    Anh Tran
    Keymaster

    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.

    #2565
    sergeysemenov
    Participant

    Thanks for assistance, Anh Tran. Provided code doesn’t get attached image. Still looking for your help.

    #2576
    Anh Tran
    Keymaster

    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>';
    }
    #2585
    sergeysemenov
    Participant

    Thank you, Anh Tran. That works.
    Good product, good support.
    Topic closed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Image Advanced’ is closed to new replies.

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash