Called if $this->type === 'media'
486842
protected function render_media(): string
    {
        \add_action('admin_enqueue_scripts', function () {
            \wp_enqueue_media();
        });

        $this->meta['disabled'] = 'disabled';

        $html = '<input id="'.\esc_attr($this->id).'" type="hidden" name="'.\esc_attr($this->name).'" value="'.
            \esc_attr($this->value).'" />';

        $html .= '<input '.$this->metaString().' id="'.
            \esc_attr($this->id).'-url" type="text" name="" value="'.
            \esc_attr(\wp_get_attachment_url($this->value)).'" />';

        $html .= ' <button id="'.
            \esc_attr($this->id).'-button" class="button">'.
            \esc_html__('Select', 'grotto-wp-field').
        '</button>';

        $html .= ' <button id="'.\esc_attr($this->id).
            '-delete" class="button submitdelete">'.
            \esc_html__('Delete', 'grotto-wp-field').
        '</button>';

        $html .= '
        <script type="text/javascript">
            (function($) {
                var grotto_uploader, attachment;';

                $html .= '
                $("#'.\esc_attr($this->id).'-button").click(function(e) {
                    e.preventDefault();';

                    $html .= '
                    if (grotto_uploader) {
                        grotto_uploader.open();
                        return;
                    }';

                    $html .= '
                    grotto_uploader = wp.media.frames.file_frame = wp.media({
                        title: "'.\esc_html__('Upload file', 'grotto-wp-field').'",
                        button: {
                            text: "'.\esc_html__('Use file', 'grotto-wp-field').'"
                        },
                        multiple: false
                    });';

                    $html .= '
                    grotto_uploader.on("select", function() {
                        attachment = grotto_uploader.state().get("selection").first().toJSON();
                        $("#'.\esc_attr($this->id).'-url").val(attachment.url);
                        $("#'.\esc_attr($this->id).'").val(attachment.id);
                    });';

                    $html .= '
                    grotto_uploader.open();
                });';

                $html .= '
                $("#'.\esc_attr($this->id).'-delete").click(function(e) {
                    e.preventDefault();';

                    $html .= '
                    $("#'.\esc_attr($this->id).'").val(0);
                    $("#'.\esc_attr($this->id).'-url").val("");
                });
            })(jQuery);
        </script>';

        return $html;
    }
248844
private function checkIfThereIsAName($media)
    {
        if (null === $media->getName() || empty($media->getName())) {
            $media->setName(preg_replace('/\\.[^.\\s]{3,4}$/', '', $media->getMediaFile()->getClientOriginalName()));
        }
    }
851768
private function performMoveMedia($type, $location, $oldName, $newName)
    {
        $from = "{$location}/{$oldName}";

        switch (Str::lower($type)) {
            case Media::MEDIA_TYPE_FILE:
                return $this->moveFile($from, $location, $newName);

            case Media::MEDIA_TYPE_DIRECTORY:
                return $this->moveDirectory($from, $location, $newName);

            default:
                return false;
        }
    }
739640
public function is($type = null)
    {
        if ($type === null) {
            return $this->is;
        } else {
            return $type == $this->is;
        }
    }
1066850
function detectType(media, options, src) {
	var mediaFiles = [];
	var i;
	var n;
	var isCanPlay;

	// Get URL and type
	if (options.type) {
		// Accept either string or array of types
		if (typeof options.type == 'string') {
			mediaFiles.push({
				type: options.type,
				url: src
			});
		} else {
			for (i = 0; i < options.type.length; i++) {
				mediaFiles.push({
					type: options.type[i],
					url: src
				});
			}
		}
	} else if (src !== null) {
		// If src attribute
		mediaFiles.push({
			type: getType(src, media.getAttribute('type')),
			url: src
		});
	} else {
		// If <source> elements
		for (i = 0; i < media.children.length; i++) {
			n = media.children[i];

			if (n.nodeType == 1 && n.tagName.toLowerCase() == 'source') {
				src = n.getAttribute('src');
				mediaFiles.push({
					type: getType(src, n.getAttribute('type')),
					url: src
				});
			}
		}
	}

	// For Android which doesn't implement the canPlayType function (always returns '')
	if (zyMedia.features.isBustedAndroid) {
		media.canPlayType = function(type) {
			return /video\/(mp4|m4v)/i.test(type) ? 'maybe' : ''
		};
	}
	// For Chromium to specify natively supported video codecs (i.e. WebM and Theora) 
	if (zyMedia.features.isChromium) {
		media.canPlayType = function(type) {
			return /video\/(webm|ogv|ogg)/i.test(type) ? 'maybe' : ''
		};
	}

	if (zyMedia.features.supportsCanPlayType) {
		for (i = 0; i < mediaFiles.length; i++) {
			// Normal detect
			if (mediaFiles[i].type == "video/m3u8" || media.canPlayType(mediaFiles[i].type).replace(/no/, '') !== ''
				// For Mac/Safari 5.0.3 which answers '' to canPlayType('audio/mp3') but 'maybe' to canPlayType('audio/mpeg')
				|| media.canPlayType(mediaFiles[i].type.replace(/mp3/, 'mpeg')).replace(/no/, '') !== ''
				// For m4a supported by detecting mp4 support
				|| media.canPlayType(mediaFiles[i].type.replace(/m4a/, 'mp4')).replace(/no/, '') !== '') {
				isCanPlay = true;
				break
			}
		}
	}

	return isCanPlay
}
260534
public function onBeforeWrite()
    {
        // Call Parent Event:
        
        parent::onBeforeWrite();
        
        // Detect Media URL Change:
        
        if ($this->isChanged('MediaURL', 2) || $this->ForceUpdate) {
            
            // Obtain Adapter Object:
            
            if ($adapter = Embed::create($this->MediaURL)) {
                
                // Define Type and Code:
                
                $this->Type   = $adapter->getType();
                $this->Code   = $adapter->getCode();
                
                // Define Dimensions:
                
                $this->Width  = $adapter->getWidth();
                $this->Height = $adapter->getHeight();
                
                // Define Title and Description:
                
                $this->MediaTitle  = $adapter->getTitle();
                $this->Description = $adapter->getDescription();
                
                // Define Aspect Ratio:
                
                $this->AspectRatio = $adapter->getAspectRatio();
                
                // Define Image URL and Dimensions:
                
                $this->ImageURL    = $adapter->getImage();
                $this->ImageWidth  = $adapter->getImageWidth();
                $this->ImageHeight = $adapter->getImageHeight();
                
            }
            
        }
    }
1256285
function($media) {
    var styles = window.getComputedStyle($media, null);
    var constraints = {
      "max-width":  "none",
      "max-height": "none",
      "min-width":  "0px",
      "min-height": "0px",
      "top": "auto",
      "right": "auto",
      "bottom": "auto",
      "left": "auto",
      "margin-top": "0px",
      "margin-right": "0px",
      "margin-bottom": "0px",
      "margin-left": "0px",
    };

    for (var property in constraints) {
      var constraint = styles.getPropertyValue(property);

      if (constraint !== constraints[property]) {
        $media.style[property] = constraints[property];
      }
    }
  }
1336036
public function updateMedia($mediaPath, $type)
    {
        $result = $this->httpPost(self::WECHAT_MEDIA_UPLOAD_PREFIX, [
            'media' => $this->uploadFile($mediaPath)
        ], [
            'access_token' => $this->getAccessToken(),
            'type' => $type
        ]);
        return isset($result['media_id']) ? $result : false;
    }
76695
function() {
			var self = this;

			$.extend( self.options, self.element.data() );

			// Use the 'type' query attribute in favor of 'post_mime_type'.
			if ( self.options.query && self.options.query.post_mime_type ) {
				self.options.query.type = self.options.query.post_mime_type;
				delete self.options.query.post_mime_type;
			}

			self._content_id = 'wp-mediapicker-content-' + self.element.attr( 'id' );

			self.element.hide().wrap( '<div class="wp-mediapicker-container" />' );

			self._wrap          = self.element.parent();
			self._open_button   = $( '<button type="button" class="wp-mediapicker-open-button button" />' ).insertAfter( self.element );
			self._remove_button = $( '<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />' ).hide().insertAfter( self._open_button ).text( self.options.label_remove );
			self._content_wrap  = $( '<div class="wp-mediapicker-content-wrap" />' ).insertAfter( self._remove_button );
			self._content       = $( '<div class="wp-mediapicker-content" />' ).appendTo( self._content_wrap ).attr( 'id', self._content_id );

			self._frame = new MediaPickerFrame({
				title: self.options.label_modal,
				buttonText: self.options.label_button,
				frame: 'select',
				state: 'insert',
				selection: new wp.media.model.Selection( [], {
					multiple: self.options.multiple
				}),
				query: self.options.query,
				multiple: self.options.multiple,
				filterable: self.options.filterable,
				searchable: self.options.searchable,
				editable: self.options.editable
			});

			self._setValue( self.element.val() );

			self._addListeners();
		}
500940
def choose_type(cls, content_type):
        """"""
        return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
            else cls.type_cls.FILE
516065
def is_premium(self, media_type):
        
        if self.logged_in:
            if media_type in self._user_data['premium']:
                return True
        return False
472243
protected function _matchType()
    {
        if (!$this->_types) {
            return true;
        }
        $file = $this->current();
        foreach ($this->_types as $type) {
            $method = 'is' . ucfirst($type);
            if ($file->$method()) {
                return true;
            }
        }
        return false;
    }
1147266
public function setType($type)
    {
        if (in_array($type, array_keys($this->devices))) {
            $this->type = $type;
        }
    }
1111729
public function allowMimetype($Mimetype) {
        if ( ! $this->returnUrl() ) return false;
        if ( isset($this->claim->accept_media_types) ) {
            $ma = $Mimetype;
            if ( ! is_array($ma) ) $ma = array($Mimetype);
            $m = new Mimeparse;
            $allowed = $m->best_match($ma, $this->claim->accept_media_types);
            if ( $Mimetype != $allowed ) return false;
            return true;
        }
        return false;
    }
387471
def filter(self, media_type, **params):
        
        mtype, msubtype = self._split_media_type(media_type)
        for x in self.__iter__():
            # all the params have to match to make the media type valid
            matched = True
            for k, v in params.items():
                if x[2].get(k, None) != v:
                    matched = False
                    break

            if matched:
                if x[0][0] == '*':
                    if x[0][1] == '*':
                        yield x

                    elif x[0][1] == msubtype:
                        yield x

                elif mtype == '*':
                    if msubtype == '*':
                        yield x

                    elif x[0][1] == msubtype:
                        yield x

                elif x[0][0] == mtype:
                    if msubtype == '*':
                        yield x

                    elif x[0][1] == '*':
                        yield x

                    elif x[0][1] == msubtype:
                        yield x
5098
protected function isBootstrapGroupUsage($type)
    {
        if( ($this->settings['group']['class'] ?? NULL) || isset($this->callableGroup) )
        {   
            if( ! $this->isCheckboxOrRadio($type) )
            {
                if( ! isset($this->settings['attr']['class']) )
                {
                    $this->settings['attr']['class'] = 'form-control';
                }
                else
                {
                    $this->settings['attr']['class'] .= ' form-control';
                }
            }
        }
    }
90548
public void setMedia(String media) throws FlickrException {
        if (media.equals("all") || media.equals("photos") || media.equals("videos")) {
            this.media = media;
        } else {
            throw new FlickrException("0", "Media type is not valid.");
        }
    }