display image of clonable group uploaded from the frontend

Support General display image of clonable group uploaded from the frontendResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27841
    julianjulian
    Participant

    hi,
    i've got a problem displaying images uploadet from the frontend to a clonable group. if i use the "single image" field and choose the images from the media library from the backend i can use...

    function subfield_preset () {
        
        $reps = rwmb_meta( 'tage' );
        asort ( $rep['repeater_datum'] ); 
        if ( ! empty( $reps ) ) {
            foreach ( $reps as $rep ) {
                if ($rep['repeater_datum'] <= date("Y-m-d")){
            
                    $image=wp_get_attachment_image($rep['repeater_bild'],array('700','700'));
                    if ( ! empty( $image ) ) {
                        echo '<img width="700" height="700" src='.$image.'<br>';
                    }
    
                }   
                else{
                    
                    //do nothing
                    
                }
            }
        }
    }

    to display the image on the frontend.

    but how do i display the image if it is uploaded through the frontend? i feel like i tried everything.

    #27869
    Long NguyenLong Nguyen
    Moderator

    Hi Julian,

    If your code works with the image uploaded on the backend, you can use the extensions MB Frontend Submission to upload the image on the frontend to show it. Get more details on the documentation https://docs.metabox.io/extensions/mb-frontend-submission/.

    #27883
    julianjulian
    Participant

    no, it doesnt work when i upload it (with "upload image" field)...it works only when i choose it from the media library (singe image).

    #27884
    julianjulian
    Participant

    the image-upload field seem to store the image differently as the single-image field. the question is which function do i have to use instead of wp_get_attachment_image to fetch the image in the front-end

    #27896
    Long NguyenLong Nguyen
    Moderator

    Hi Julian,

    Yes, there is a difference when storing data between the field type image_upload and single_image. The field type image_upload has the settings 'multiple' => true which means the value returned is an array. You need to use the loop to iterate through array elements, like the cloneable field.

    Get more details on the documentation https://docs.metabox.io/fields/image-upload/#template-usage

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.