wp_mime_type_icon example

$file = get_attached_file( $post->ID );

    if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
        // We have a thumbnail desired, specified and existing.
        $src_file = wp_basename($src);
    } elseif ( wp_attachment_is_image( $post->ID ) ) {
        // We have an image without a thumbnail.
        $src = wp_get_attachment_url( $post->ID );
        $src_file = & $file;
    } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
        // No thumb, no image. We'll look for a mime-related icon instead.
        /** This filter is documented in wp-includes/post.php */
        $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
        $src_file = $icon_dir . '/' . wp_basename($src);
    }

    if ( !isset($src) || !$src )
        return false;

    return array($src$src_file);
}
/* * Fake an attachment model - needs all fields used by template. * Note that the default value must be a URL, NOT an attachment ID. */
                $ext  = substr( $this->setting->default, -3 );
                $type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp', 'webp' ), true ) ? 'image' : 'document';

                $default_attachment = array(
                    'id'    => 1,
                    'url'   => $this->setting->default,
                    'type'  => $type,
                    'icon'  => wp_mime_type_icon( $type ),
                    'title' => wp_basename( $this->setting->default ),
                );

                if ( 'image' === $type ) {
                    $default_attachment['sizes'] = array(
                        'full' => array( 'url' => $this->setting->default ),
                    );
                }

                $this->json['defaultAttachment'] = $default_attachment;
            }

            

function wp_get_attachment_image_src( $attachment_id$size = 'thumbnail', $icon = false ) {
    // Get a thumbnail or intermediate image if there is one.     $image = image_downsize( $attachment_id$size );
    if ( ! $image ) {
        $src = false;

        if ( $icon ) {
            $src = wp_mime_type_icon( $attachment_id );

            if ( $src ) {
                /** This filter is documented in wp-includes/post.php */
                $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );

                $src_file               = $icon_dir . '/' . wp_basename( $src );
                list( $width$height ) = wp_getimagesize( $src_file );
            }
        }

        if ( $src && $width && $height ) {
            
Home | Imprint | This part of the site doesn't use cookies.