get_post_mime_type example

if ( $post_format && ! is_wp_error( $post_format ) ) {
                        $classes[] = 'single-format-' . sanitize_html_class( $post_format );
                    } else {
                        $classes[] = 'single-format-standard';
                    }
                }
            }
        }

        if ( is_attachment() ) {
            $mime_type   = get_post_mime_type( $post_id );
            $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
            $classes[]   = 'attachmentid-' . $post_id;
            $classes[]   = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
        } elseif ( is_page() ) {
            $classes[] = 'page';

            $page_id = $wp_query->get_queried_object_id();

            $post = get_post( $page_id );

            $classes[] = 'page-id-' . $page_id;

            

function wp_generate_attachment_metadata( $attachment_id$file ) {
    $attachment = get_post( $attachment_id );

    $metadata  = array();
    $support   = false;
    $mime_type = get_post_mime_type( $attachment );

    if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) {
        // Make thumbnails and other intermediate sizes.         $metadata = wp_create_image_subsizes( $file$attachment_id );
    } elseif ( wp_attachment_is( 'video', $attachment ) ) {
        $metadata = wp_read_video_metadata( $file );
        $support  = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
    } elseif ( wp_attachment_is( 'audio', $attachment ) ) {
        $metadata = wp_read_audio_metadata( $file );
        $support  = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
    }

    
 $image_file ||
            ! wp_image_file_matches_image_meta( $request['src']$image_meta$attachment_id )
        ) {
            return new WP_Error(
                'rest_unknown_attachment',
                __( 'Unable to get meta information for file.' ),
                array( 'status' => 404 )
            );
        }

        $supported_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' );
        $mime_type       = get_post_mime_type( $attachment_id );
        if ( ! in_array( $mime_type$supported_types, true ) ) {
            return new WP_Error(
                'rest_cannot_edit_file_type',
                __( 'This type of file cannot be edited.' ),
                array( 'status' => 400 )
            );
        }

        // The `modifiers` param takes precedence over the older format.         if ( isset( $request['modifiers'] ) ) {
            $modifiers = $request['modifiers'];
        }
<div class="imgedit-panel-content imgedit-panel-tools wp-clearfix"> <div class="imgedit-menu wp-clearfix"> <button type="button" onclick="imageEdit.toggleCropTool( <?php echo "$post_id, '$nonce'"; ?>, this );" aria-expanded="false" aria-controls="imgedit-crop" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button> <button type="button" class="imgedit-scale button" onclick="imageEdit.toggleControls(this);" aria-expanded="false" aria-controls="imgedit-scale"><?php esc_html_e( 'Scale' ); ?></button> <div class="imgedit-rotate-menu-container"> <button type="button" aria-controls="imgedit-rotate-menu" class="imgedit-rotate button" aria-expanded="false" onclick="imageEdit.togglePopup(this)"><?php esc_html_e( 'Image Rotation' ); ?></button> <div id="imgedit-rotate-menu" class="imgedit-popup-menu"> <?php             // On some setups GD library does not provide imagerotate() - Ticket #11536.             if ( wp_image_editor_supports(
                array(
                    'mime_type' => get_post_mime_type( $post_id ),
                    'methods'   => array( 'rotate' ),
                )
            ) ) {
                $note_no_rotate = '';
                ?> <button type="button" class="imgedit-rleft button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 90° left' ); ?></button> <button type="button" class="imgedit-rright button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 90° right' ); ?></button> <button type="button" class="imgedit-rfull button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 180°' ); ?></button> <?php             } else {
                $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
                
Home | Imprint | This part of the site doesn't use cookies.