Media Edit

Support General Media Edit

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1737
    carassiuscarassius
    Participant

    I remember seeing an example tutorial on adding a metabox to the media post edit screen, but cannot seem to locate it now? Am I imagining things?

    #1738
    carassiuscarassius
    Participant

    I have the meta in the attachment post but cannot get the value in the front end?
    Code:

     $prefix = 'sw_';
    
           // media meta box
            $meta_boxes[] = array(
                'id'       => 'href',
                'title'    => 'Link for Horizontal Gallery',
                'pages'    => array('attachment'),
                'context'  => 'normal',
                'priority' => 'high',
    
                'fields' => array(            
    
                    array(
                        'name'  => 'URL',
                        'id'    => $prefix . 'link',
                        'type'  => 'url',
                    ),
    
                )
            );

    But $links = rwmb_meta( 'sw_link', 'type=url' ); doesnt return any value when I do a var_dump?
    That is why I was trying to find that tutorial I thought I had seen before

    #1740
    Anh TranAnh Tran
    Keymaster

    The rwmb_meta returns the value for current post. So the code above works only if you're viewing the attachment page. To make sure it works, you can provide the attachment ID as the 3rd param: rwmb_meta( 'sw_link', 'type=url', $attachment_id );

    #1741
    carassiuscarassius
    Participant

    yeah I have it working the same way (well should be) with get_post_meta and changed to use the rwmb_meta, but I get the same problem using either method, the variable is not echoing

    $images = rwmb_meta( 'sw_gallery_image', 'type=image' );
    foreach ( $images as $image ) {
    $imgID = $image['ID'];
    $url = rwmb_meta( 'sw_link', 'type=url', $imgID );
    echo "<a href=' . $url . '></a>";

    If I do a var_dump($url); I get the metabox value return, but in the link it isnt, any suggestions?

    this was my post_meta $url = get_post_meta($imgID, 'sw_link');

    #1742
    carassiuscarassius
    Participant

    resolved

    #1755
    Anh TranAnh Tran
    Keymaster

    Glad that you made it 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Media Edit’ is closed to new replies.