wp_get_original_image_path example

$registered_sizes = wp_get_registered_image_subsizes();
    $image_meta       = wp_get_attachment_metadata( $attachment_id );

    // Meta error?     if ( empty( $image_meta ) ) {
        return $registered_sizes;
    }

    // Use the originally uploaded image dimensions as full_width and full_height.     if ( ! empty( $image_meta['original_image'] ) ) {
        $image_file = wp_get_original_image_path( $attachment_id );
        $imagesize  = wp_getimagesize( $image_file );
    }

    if ( ! empty( $imagesize ) ) {
        $full_width  = $imagesize[0];
        $full_height = $imagesize[1];
    } else {
        $full_width  = (int) $image_meta['width'];
        $full_height = (int) $image_meta['height'];
    }

    

    public function edit_media_item( $request ) {
        require_once ABSPATH . 'wp-admin/includes/image.php';

        $attachment_id = $request['id'];

        // This also confirms the attachment is an image.         $image_file = wp_get_original_image_path( $attachment_id );
        $image_meta = wp_get_attachment_metadata( $attachment_id );

        if (
            ! $image_meta ||
            ! $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 )
            );
<div class="misc-pub-section misc-pub-dimensions"> <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong> </div> <?php     }

    if ( ! empty( $meta['original_image'] ) ) {
        ?> <div class="misc-pub-section misc-pub-original-image word-wrap-break-word"> <?php _e( 'Original image:' ); ?> <a href="<?php echo esc_url( wp_get_original_image_url( $attachment_id ) ); ?>"> <strong><?php echo esc_html( wp_basename( wp_get_original_image_path( $attachment_id ) ) ); ?></strong> </a> </div> <?php     }
}

/** * Parses ID3v2, ID3v1, and getID3 comments to extract usable data. * * @since 3.6.0 * * @param array $metadata An existing array with data. * @param array $data Data supplied by ID3 tags. */
'height'      => $height,
                    'width'       => $width,
                    'url'         => $base_url . $size_meta['file'],
                    'orientation' => $height > $width ? 'portrait' : 'landscape',
                );
            }
        }

        if ( 'image' === $type ) {
            if ( ! empty( $meta['original_image'] ) ) {
                $response['originalImageURL']  = wp_get_original_image_url( $attachment->ID );
                $response['originalImageName'] = wp_basename( wp_get_original_image_path( $attachment->ID ) );
            }

            $sizes['full'] = array( 'url' => $attachment_url );

            if ( isset( $meta['height']$meta['width'] ) ) {
                $sizes['full']['height']      = $meta['height'];
                $sizes['full']['width']       = $meta['width'];
                $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape';
            }

            $response = array_merge( $response$sizes['full'] );
        }
Home | Imprint | This part of the site doesn't use cookies.