Custom Fields
Re-Envisioned
Support Announcements display image of clonable group uploaded from the frontend

  • Creator
    Topic
  • #27841
    Resolved julian
    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #27869
    Long 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
    julian
    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
    julian
    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 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 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.