CMB2_Type_Oembed

CMB oembed field type.

Defined (1)

The class is defined in the following location(s).

/includes/types/CMB2_Type_Oembed.php  
  1. class CMB2_Type_Oembed extends CMB2_Type_Text { 
  2.  
  3. public function render() { 
  4. $field = $this->field; 
  5.  
  6. $meta_value = trim( $field->escaped_value() ); 
  7.  
  8. $oembed = ! empty( $meta_value ) 
  9. ? cmb2_ajax()->get_oembed( array( 
  10. 'url' => $field->escaped_value(),  
  11. 'object_id' => $field->object_id,  
  12. 'object_type' => $field->object_type,  
  13. 'oembed_args' => array( 'width' => '640' ),  
  14. 'field_id' => $this->_id(),  
  15. ) ) 
  16. : ''; 
  17.  
  18. return parent::render( array( 
  19. 'class' => 'cmb2-oembed regular-text',  
  20. 'data-objectid' => $field->object_id,  
  21. 'data-objecttype' => $field->object_type,  
  22. ) ) 
  23. . '<p class="cmb-spinner spinner" style="display:none;"></p>' 
  24. . '<div id="'. $this->_id( '-status' ). '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>'; 
  25.