Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: media.php
*
[4000] Fix | Delete
* @type int $0 The maximum width in pixels.
[4001] Fix | Delete
* @type int $1 The maximum height in pixels.
[4002] Fix | Delete
* }
[4003] Fix | Delete
*/
[4004] Fix | Delete
function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) {
[4005] Fix | Delete
$example_width = (int) $example_width;
[4006] Fix | Delete
$example_height = (int) $example_height;
[4007] Fix | Delete
$max_width = (int) $max_width;
[4008] Fix | Delete
$max_height = (int) $max_height;
[4009] Fix | Delete
[4010] Fix | Delete
return wp_constrain_dimensions( $example_width * 1000000, $example_height * 1000000, $max_width, $max_height );
[4011] Fix | Delete
}
[4012] Fix | Delete
[4013] Fix | Delete
/**
[4014] Fix | Delete
* Determines the maximum upload size allowed in php.ini.
[4015] Fix | Delete
*
[4016] Fix | Delete
* @since 2.5.0
[4017] Fix | Delete
*
[4018] Fix | Delete
* @return int Allowed upload size.
[4019] Fix | Delete
*/
[4020] Fix | Delete
function wp_max_upload_size() {
[4021] Fix | Delete
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
[4022] Fix | Delete
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
[4023] Fix | Delete
[4024] Fix | Delete
/**
[4025] Fix | Delete
* Filters the maximum upload size allowed in php.ini.
[4026] Fix | Delete
*
[4027] Fix | Delete
* @since 2.5.0
[4028] Fix | Delete
*
[4029] Fix | Delete
* @param int $size Max upload size limit in bytes.
[4030] Fix | Delete
* @param int $u_bytes Maximum upload filesize in bytes.
[4031] Fix | Delete
* @param int $p_bytes Maximum size of POST data in bytes.
[4032] Fix | Delete
*/
[4033] Fix | Delete
return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
[4034] Fix | Delete
}
[4035] Fix | Delete
[4036] Fix | Delete
/**
[4037] Fix | Delete
* Returns a WP_Image_Editor instance and loads file into it.
[4038] Fix | Delete
*
[4039] Fix | Delete
* @since 3.5.0
[4040] Fix | Delete
*
[4041] Fix | Delete
* @param string $path Path to the file to load.
[4042] Fix | Delete
* @param array $args Optional. Additional arguments for retrieving the image editor.
[4043] Fix | Delete
* Default empty array.
[4044] Fix | Delete
* @return WP_Image_Editor|WP_Error The WP_Image_Editor object on success,
[4045] Fix | Delete
* a WP_Error object otherwise.
[4046] Fix | Delete
*/
[4047] Fix | Delete
function wp_get_image_editor( $path, $args = array() ) {
[4048] Fix | Delete
$args['path'] = $path;
[4049] Fix | Delete
[4050] Fix | Delete
// If the mime type is not set in args, try to extract and set it from the file.
[4051] Fix | Delete
if ( ! isset( $args['mime_type'] ) ) {
[4052] Fix | Delete
$file_info = wp_check_filetype( $args['path'] );
[4053] Fix | Delete
[4054] Fix | Delete
/*
[4055] Fix | Delete
* If $file_info['type'] is false, then we let the editor attempt to
[4056] Fix | Delete
* figure out the file type, rather than forcing a failure based on extension.
[4057] Fix | Delete
*/
[4058] Fix | Delete
if ( isset( $file_info ) && $file_info['type'] ) {
[4059] Fix | Delete
$args['mime_type'] = $file_info['type'];
[4060] Fix | Delete
}
[4061] Fix | Delete
}
[4062] Fix | Delete
[4063] Fix | Delete
// Check and set the output mime type mapped to the input type.
[4064] Fix | Delete
if ( isset( $args['mime_type'] ) ) {
[4065] Fix | Delete
/** This filter is documented in wp-includes/class-wp-image-editor.php */
[4066] Fix | Delete
$output_format = apply_filters( 'image_editor_output_format', array(), $path, $args['mime_type'] );
[4067] Fix | Delete
if ( isset( $output_format[ $args['mime_type'] ] ) ) {
[4068] Fix | Delete
$args['output_mime_type'] = $output_format[ $args['mime_type'] ];
[4069] Fix | Delete
}
[4070] Fix | Delete
}
[4071] Fix | Delete
[4072] Fix | Delete
$implementation = _wp_image_editor_choose( $args );
[4073] Fix | Delete
[4074] Fix | Delete
if ( $implementation ) {
[4075] Fix | Delete
$editor = new $implementation( $path );
[4076] Fix | Delete
$loaded = $editor->load();
[4077] Fix | Delete
[4078] Fix | Delete
if ( is_wp_error( $loaded ) ) {
[4079] Fix | Delete
return $loaded;
[4080] Fix | Delete
}
[4081] Fix | Delete
[4082] Fix | Delete
return $editor;
[4083] Fix | Delete
}
[4084] Fix | Delete
[4085] Fix | Delete
return new WP_Error( 'image_no_editor', __( 'No editor could be selected.' ) );
[4086] Fix | Delete
}
[4087] Fix | Delete
[4088] Fix | Delete
/**
[4089] Fix | Delete
* Tests whether there is an editor that supports a given mime type or methods.
[4090] Fix | Delete
*
[4091] Fix | Delete
* @since 3.5.0
[4092] Fix | Delete
*
[4093] Fix | Delete
* @param string|array $args Optional. Array of arguments to retrieve the image editor supports.
[4094] Fix | Delete
* Default empty array.
[4095] Fix | Delete
* @return bool True if an eligible editor is found; false otherwise.
[4096] Fix | Delete
*/
[4097] Fix | Delete
function wp_image_editor_supports( $args = array() ) {
[4098] Fix | Delete
return (bool) _wp_image_editor_choose( $args );
[4099] Fix | Delete
}
[4100] Fix | Delete
[4101] Fix | Delete
/**
[4102] Fix | Delete
* Tests which editors are capable of supporting the request.
[4103] Fix | Delete
*
[4104] Fix | Delete
* @ignore
[4105] Fix | Delete
* @since 3.5.0
[4106] Fix | Delete
*
[4107] Fix | Delete
* @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
[4108] Fix | Delete
* @return string|false Class name for the first editor that claims to support the request.
[4109] Fix | Delete
* False if no editor claims to support the request.
[4110] Fix | Delete
*/
[4111] Fix | Delete
function _wp_image_editor_choose( $args = array() ) {
[4112] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
[4113] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
[4114] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
[4115] Fix | Delete
require_once ABSPATH . WPINC . '/class-avif-info.php';
[4116] Fix | Delete
/**
[4117] Fix | Delete
* Filters the list of image editing library classes.
[4118] Fix | Delete
*
[4119] Fix | Delete
* @since 3.5.0
[4120] Fix | Delete
*
[4121] Fix | Delete
* @param string[] $image_editors Array of available image editor class names. Defaults are
[4122] Fix | Delete
* 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
[4123] Fix | Delete
*/
[4124] Fix | Delete
$implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) );
[4125] Fix | Delete
$supports_input = false;
[4126] Fix | Delete
[4127] Fix | Delete
foreach ( $implementations as $implementation ) {
[4128] Fix | Delete
if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) {
[4129] Fix | Delete
continue;
[4130] Fix | Delete
}
[4131] Fix | Delete
[4132] Fix | Delete
// Implementation should support the passed mime type.
[4133] Fix | Delete
if ( isset( $args['mime_type'] ) &&
[4134] Fix | Delete
! call_user_func(
[4135] Fix | Delete
array( $implementation, 'supports_mime_type' ),
[4136] Fix | Delete
$args['mime_type']
[4137] Fix | Delete
) ) {
[4138] Fix | Delete
continue;
[4139] Fix | Delete
}
[4140] Fix | Delete
[4141] Fix | Delete
// Implementation should support requested methods.
[4142] Fix | Delete
if ( isset( $args['methods'] ) &&
[4143] Fix | Delete
array_diff( $args['methods'], get_class_methods( $implementation ) ) ) {
[4144] Fix | Delete
[4145] Fix | Delete
continue;
[4146] Fix | Delete
}
[4147] Fix | Delete
[4148] Fix | Delete
// Implementation should ideally support the output mime type as well if set and different than the passed type.
[4149] Fix | Delete
if (
[4150] Fix | Delete
isset( $args['mime_type'] ) &&
[4151] Fix | Delete
isset( $args['output_mime_type'] ) &&
[4152] Fix | Delete
$args['mime_type'] !== $args['output_mime_type'] &&
[4153] Fix | Delete
! call_user_func( array( $implementation, 'supports_mime_type' ), $args['output_mime_type'] )
[4154] Fix | Delete
) {
[4155] Fix | Delete
/*
[4156] Fix | Delete
* This implementation supports the input type but not the output type.
[4157] Fix | Delete
* Keep looking to see if we can find an implementation that supports both.
[4158] Fix | Delete
*/
[4159] Fix | Delete
$supports_input = $implementation;
[4160] Fix | Delete
continue;
[4161] Fix | Delete
}
[4162] Fix | Delete
[4163] Fix | Delete
// Favor the implementation that supports both input and output mime types.
[4164] Fix | Delete
return $implementation;
[4165] Fix | Delete
}
[4166] Fix | Delete
[4167] Fix | Delete
return $supports_input;
[4168] Fix | Delete
}
[4169] Fix | Delete
[4170] Fix | Delete
/**
[4171] Fix | Delete
* Prints default Plupload arguments.
[4172] Fix | Delete
*
[4173] Fix | Delete
* @since 3.4.0
[4174] Fix | Delete
*/
[4175] Fix | Delete
function wp_plupload_default_settings() {
[4176] Fix | Delete
$wp_scripts = wp_scripts();
[4177] Fix | Delete
[4178] Fix | Delete
$data = $wp_scripts->get_data( 'wp-plupload', 'data' );
[4179] Fix | Delete
if ( $data && str_contains( $data, '_wpPluploadSettings' ) ) {
[4180] Fix | Delete
return;
[4181] Fix | Delete
}
[4182] Fix | Delete
[4183] Fix | Delete
$max_upload_size = wp_max_upload_size();
[4184] Fix | Delete
$allowed_extensions = array_keys( get_allowed_mime_types() );
[4185] Fix | Delete
$extensions = array();
[4186] Fix | Delete
foreach ( $allowed_extensions as $extension ) {
[4187] Fix | Delete
$extensions = array_merge( $extensions, explode( '|', $extension ) );
[4188] Fix | Delete
}
[4189] Fix | Delete
[4190] Fix | Delete
/*
[4191] Fix | Delete
* Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`,
[4192] Fix | Delete
* and the `flash_swf_url` and `silverlight_xap_url` are not used.
[4193] Fix | Delete
*/
[4194] Fix | Delete
$defaults = array(
[4195] Fix | Delete
'file_data_name' => 'async-upload', // Key passed to $_FILE.
[4196] Fix | Delete
'url' => admin_url( 'async-upload.php', 'relative' ),
[4197] Fix | Delete
'filters' => array(
[4198] Fix | Delete
'max_file_size' => $max_upload_size . 'b',
[4199] Fix | Delete
'mime_types' => array( array( 'extensions' => implode( ',', $extensions ) ) ),
[4200] Fix | Delete
),
[4201] Fix | Delete
);
[4202] Fix | Delete
[4203] Fix | Delete
/*
[4204] Fix | Delete
* Currently only iOS Safari supports multiple files uploading,
[4205] Fix | Delete
* but iOS 7.x has a bug that prevents uploading of videos when enabled.
[4206] Fix | Delete
* See #29602.
[4207] Fix | Delete
*/
[4208] Fix | Delete
if ( wp_is_mobile()
[4209] Fix | Delete
&& str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' )
[4210] Fix | Delete
&& str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' )
[4211] Fix | Delete
) {
[4212] Fix | Delete
$defaults['multi_selection'] = false;
[4213] Fix | Delete
}
[4214] Fix | Delete
[4215] Fix | Delete
// Check if WebP images can be edited.
[4216] Fix | Delete
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
[4217] Fix | Delete
$defaults['webp_upload_error'] = true;
[4218] Fix | Delete
}
[4219] Fix | Delete
[4220] Fix | Delete
// Check if AVIF images can be edited.
[4221] Fix | Delete
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
[4222] Fix | Delete
$defaults['avif_upload_error'] = true;
[4223] Fix | Delete
}
[4224] Fix | Delete
[4225] Fix | Delete
/**
[4226] Fix | Delete
* Filters the Plupload default settings.
[4227] Fix | Delete
*
[4228] Fix | Delete
* @since 3.4.0
[4229] Fix | Delete
*
[4230] Fix | Delete
* @param array $defaults Default Plupload settings array.
[4231] Fix | Delete
*/
[4232] Fix | Delete
$defaults = apply_filters( 'plupload_default_settings', $defaults );
[4233] Fix | Delete
[4234] Fix | Delete
$params = array(
[4235] Fix | Delete
'action' => 'upload-attachment',
[4236] Fix | Delete
);
[4237] Fix | Delete
[4238] Fix | Delete
/**
[4239] Fix | Delete
* Filters the Plupload default parameters.
[4240] Fix | Delete
*
[4241] Fix | Delete
* @since 3.4.0
[4242] Fix | Delete
*
[4243] Fix | Delete
* @param array $params Default Plupload parameters array.
[4244] Fix | Delete
*/
[4245] Fix | Delete
$params = apply_filters( 'plupload_default_params', $params );
[4246] Fix | Delete
[4247] Fix | Delete
$params['_wpnonce'] = wp_create_nonce( 'media-form' );
[4248] Fix | Delete
[4249] Fix | Delete
$defaults['multipart_params'] = $params;
[4250] Fix | Delete
[4251] Fix | Delete
$settings = array(
[4252] Fix | Delete
'defaults' => $defaults,
[4253] Fix | Delete
'browser' => array(
[4254] Fix | Delete
'mobile' => wp_is_mobile(),
[4255] Fix | Delete
'supported' => _device_can_upload(),
[4256] Fix | Delete
),
[4257] Fix | Delete
'limitExceeded' => is_multisite() && ! is_upload_space_available(),
[4258] Fix | Delete
);
[4259] Fix | Delete
[4260] Fix | Delete
$script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';';
[4261] Fix | Delete
[4262] Fix | Delete
if ( $data ) {
[4263] Fix | Delete
$script = "$data\n$script";
[4264] Fix | Delete
}
[4265] Fix | Delete
[4266] Fix | Delete
$wp_scripts->add_data( 'wp-plupload', 'data', $script );
[4267] Fix | Delete
}
[4268] Fix | Delete
[4269] Fix | Delete
/**
[4270] Fix | Delete
* Prepares an attachment post object for JS, where it is expected
[4271] Fix | Delete
* to be JSON-encoded and fit into an Attachment model.
[4272] Fix | Delete
*
[4273] Fix | Delete
* @since 3.5.0
[4274] Fix | Delete
*
[4275] Fix | Delete
* @param int|WP_Post $attachment Attachment ID or object.
[4276] Fix | Delete
* @return array|void {
[4277] Fix | Delete
* Array of attachment details, or void if the parameter does not correspond to an attachment.
[4278] Fix | Delete
*
[4279] Fix | Delete
* @type string $alt Alt text of the attachment.
[4280] Fix | Delete
* @type string $author ID of the attachment author, as a string.
[4281] Fix | Delete
* @type string $authorName Name of the attachment author.
[4282] Fix | Delete
* @type string $caption Caption for the attachment.
[4283] Fix | Delete
* @type array $compat Containing item and meta.
[4284] Fix | Delete
* @type string $context Context, whether it's used as the site icon for example.
[4285] Fix | Delete
* @type int $date Uploaded date, timestamp in milliseconds.
[4286] Fix | Delete
* @type string $dateFormatted Formatted date (e.g. June 29, 2018).
[4287] Fix | Delete
* @type string $description Description of the attachment.
[4288] Fix | Delete
* @type string $editLink URL to the edit page for the attachment.
[4289] Fix | Delete
* @type string $filename File name of the attachment.
[4290] Fix | Delete
* @type string $filesizeHumanReadable Filesize of the attachment in human readable format (e.g. 1 MB).
[4291] Fix | Delete
* @type int $filesizeInBytes Filesize of the attachment in bytes.
[4292] Fix | Delete
* @type int $height If the attachment is an image, represents the height of the image in pixels.
[4293] Fix | Delete
* @type string $icon Icon URL of the attachment (e.g. /wp-includes/images/media/archive.png).
[4294] Fix | Delete
* @type int $id ID of the attachment.
[4295] Fix | Delete
* @type string $link URL to the attachment.
[4296] Fix | Delete
* @type int $menuOrder Menu order of the attachment post.
[4297] Fix | Delete
* @type array $meta Meta data for the attachment.
[4298] Fix | Delete
* @type string $mime Mime type of the attachment (e.g. image/jpeg or application/zip).
[4299] Fix | Delete
* @type int $modified Last modified, timestamp in milliseconds.
[4300] Fix | Delete
* @type string $name Name, same as title of the attachment.
[4301] Fix | Delete
* @type array $nonces Nonces for update, delete and edit.
[4302] Fix | Delete
* @type string $orientation If the attachment is an image, represents the image orientation
[4303] Fix | Delete
* (landscape or portrait).
[4304] Fix | Delete
* @type array $sizes If the attachment is an image, contains an array of arrays
[4305] Fix | Delete
* for the images sizes: thumbnail, medium, large, and full.
[4306] Fix | Delete
* @type string $status Post status of the attachment (usually 'inherit').
[4307] Fix | Delete
* @type string $subtype Mime subtype of the attachment (usually the last part, e.g. jpeg or zip).
[4308] Fix | Delete
* @type string $title Title of the attachment (usually slugified file name without the extension).
[4309] Fix | Delete
* @type string $type Type of the attachment (usually first part of the mime type, e.g. image).
[4310] Fix | Delete
* @type int $uploadedTo Parent post to which the attachment was uploaded.
[4311] Fix | Delete
* @type string $uploadedToLink URL to the edit page of the parent post of the attachment.
[4312] Fix | Delete
* @type string $uploadedToTitle Post title of the parent of the attachment.
[4313] Fix | Delete
* @type string $url Direct URL to the attachment file (from wp-content).
[4314] Fix | Delete
* @type int $width If the attachment is an image, represents the width of the image in pixels.
[4315] Fix | Delete
* }
[4316] Fix | Delete
*
[4317] Fix | Delete
*/
[4318] Fix | Delete
function wp_prepare_attachment_for_js( $attachment ) {
[4319] Fix | Delete
$attachment = get_post( $attachment );
[4320] Fix | Delete
[4321] Fix | Delete
if ( ! $attachment ) {
[4322] Fix | Delete
return;
[4323] Fix | Delete
}
[4324] Fix | Delete
[4325] Fix | Delete
if ( 'attachment' !== $attachment->post_type ) {
[4326] Fix | Delete
return;
[4327] Fix | Delete
}
[4328] Fix | Delete
[4329] Fix | Delete
$meta = wp_get_attachment_metadata( $attachment->ID );
[4330] Fix | Delete
if ( str_contains( $attachment->post_mime_type, '/' ) ) {
[4331] Fix | Delete
list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
[4332] Fix | Delete
} else {
[4333] Fix | Delete
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
[4334] Fix | Delete
}
[4335] Fix | Delete
[4336] Fix | Delete
$attachment_url = wp_get_attachment_url( $attachment->ID );
[4337] Fix | Delete
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
[4338] Fix | Delete
[4339] Fix | Delete
$response = array(
[4340] Fix | Delete
'id' => $attachment->ID,
[4341] Fix | Delete
'title' => $attachment->post_title,
[4342] Fix | Delete
'filename' => wp_basename( get_attached_file( $attachment->ID ) ),
[4343] Fix | Delete
'url' => $attachment_url,
[4344] Fix | Delete
'link' => get_attachment_link( $attachment->ID ),
[4345] Fix | Delete
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
[4346] Fix | Delete
'author' => $attachment->post_author,
[4347] Fix | Delete
'description' => $attachment->post_content,
[4348] Fix | Delete
'caption' => $attachment->post_excerpt,
[4349] Fix | Delete
'name' => $attachment->post_name,
[4350] Fix | Delete
'status' => $attachment->post_status,
[4351] Fix | Delete
'uploadedTo' => $attachment->post_parent,
[4352] Fix | Delete
'date' => strtotime( $attachment->post_date_gmt ) * 1000,
[4353] Fix | Delete
'modified' => strtotime( $attachment->post_modified_gmt ) * 1000,
[4354] Fix | Delete
'menuOrder' => $attachment->menu_order,
[4355] Fix | Delete
'mime' => $attachment->post_mime_type,
[4356] Fix | Delete
'type' => $type,
[4357] Fix | Delete
'subtype' => $subtype,
[4358] Fix | Delete
'icon' => wp_mime_type_icon( $attachment->ID, '.svg' ),
[4359] Fix | Delete
'dateFormatted' => mysql2date( __( 'F j, Y' ), $attachment->post_date ),
[4360] Fix | Delete
'nonces' => array(
[4361] Fix | Delete
'update' => false,
[4362] Fix | Delete
'delete' => false,
[4363] Fix | Delete
'edit' => false,
[4364] Fix | Delete
),
[4365] Fix | Delete
'editLink' => false,
[4366] Fix | Delete
'meta' => false,
[4367] Fix | Delete
);
[4368] Fix | Delete
[4369] Fix | Delete
$author = new WP_User( $attachment->post_author );
[4370] Fix | Delete
[4371] Fix | Delete
if ( $author->exists() ) {
[4372] Fix | Delete
$author_name = $author->display_name ? $author->display_name : $author->nickname;
[4373] Fix | Delete
$response['authorName'] = html_entity_decode( $author_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
[4374] Fix | Delete
$response['authorLink'] = get_edit_user_link( $author->ID );
[4375] Fix | Delete
} else {
[4376] Fix | Delete
$response['authorName'] = __( '(no author)' );
[4377] Fix | Delete
}
[4378] Fix | Delete
[4379] Fix | Delete
if ( $attachment->post_parent ) {
[4380] Fix | Delete
$post_parent = get_post( $attachment->post_parent );
[4381] Fix | Delete
if ( $post_parent && current_user_can( 'read_post', $attachment->post_parent ) ) {
[4382] Fix | Delete
$response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
[4383] Fix | Delete
$response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' );
[4384] Fix | Delete
}
[4385] Fix | Delete
}
[4386] Fix | Delete
[4387] Fix | Delete
$attached_file = get_attached_file( $attachment->ID );
[4388] Fix | Delete
[4389] Fix | Delete
if ( isset( $meta['filesize'] ) ) {
[4390] Fix | Delete
$bytes = $meta['filesize'];
[4391] Fix | Delete
} elseif ( file_exists( $attached_file ) ) {
[4392] Fix | Delete
$bytes = wp_filesize( $attached_file );
[4393] Fix | Delete
} else {
[4394] Fix | Delete
$bytes = '';
[4395] Fix | Delete
}
[4396] Fix | Delete
[4397] Fix | Delete
if ( $bytes ) {
[4398] Fix | Delete
$response['filesizeInBytes'] = $bytes;
[4399] Fix | Delete
$response['filesizeHumanReadable'] = size_format( $bytes );
[4400] Fix | Delete
}
[4401] Fix | Delete
[4402] Fix | Delete
$context = get_post_meta( $attachment->ID, '_wp_attachment_context', true );
[4403] Fix | Delete
$response['context'] = ( $context ) ? $context : '';
[4404] Fix | Delete
[4405] Fix | Delete
if ( current_user_can( 'edit_post', $attachment->ID ) ) {
[4406] Fix | Delete
$response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );
[4407] Fix | Delete
$response['nonces']['edit'] = wp_create_nonce( 'image_editor-' . $attachment->ID );
[4408] Fix | Delete
$response['editLink'] = get_edit_post_link( $attachment->ID, 'raw' );
[4409] Fix | Delete
}
[4410] Fix | Delete
[4411] Fix | Delete
if ( current_user_can( 'delete_post', $attachment->ID ) ) {
[4412] Fix | Delete
$response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID );
[4413] Fix | Delete
}
[4414] Fix | Delete
[4415] Fix | Delete
if ( $meta && ( 'image' === $type || ! empty( $meta['sizes'] ) ) ) {
[4416] Fix | Delete
$sizes = array();
[4417] Fix | Delete
[4418] Fix | Delete
/** This filter is documented in wp-admin/includes/media.php */
[4419] Fix | Delete
$possible_sizes = apply_filters(
[4420] Fix | Delete
'image_size_names_choose',
[4421] Fix | Delete
array(
[4422] Fix | Delete
'thumbnail' => __( 'Thumbnail' ),
[4423] Fix | Delete
'medium' => __( 'Medium' ),
[4424] Fix | Delete
'large' => __( 'Large' ),
[4425] Fix | Delete
'full' => __( 'Full Size' ),
[4426] Fix | Delete
)
[4427] Fix | Delete
);
[4428] Fix | Delete
unset( $possible_sizes['full'] );
[4429] Fix | Delete
[4430] Fix | Delete
/*
[4431] Fix | Delete
* Loop through all potential sizes that may be chosen. Try to do this with some efficiency.
[4432] Fix | Delete
* First: run the image_downsize filter. If it returns something, we can use its data.
[4433] Fix | Delete
* If the filter does not return something, then image_downsize() is just an expensive way
[4434] Fix | Delete
* to check the image metadata, which we do second.
[4435] Fix | Delete
*/
[4436] Fix | Delete
foreach ( $possible_sizes as $size => $label ) {
[4437] Fix | Delete
[4438] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[4439] Fix | Delete
$downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size );
[4440] Fix | Delete
[4441] Fix | Delete
if ( $downsize ) {
[4442] Fix | Delete
if ( empty( $downsize[3] ) ) {
[4443] Fix | Delete
continue;
[4444] Fix | Delete
}
[4445] Fix | Delete
[4446] Fix | Delete
$sizes[ $size ] = array(
[4447] Fix | Delete
'height' => $downsize[2],
[4448] Fix | Delete
'width' => $downsize[1],
[4449] Fix | Delete
'url' => $downsize[0],
[4450] Fix | Delete
'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape',
[4451] Fix | Delete
);
[4452] Fix | Delete
} elseif ( isset( $meta['sizes'][ $size ] ) ) {
[4453] Fix | Delete
// Nothing from the filter, so consult image metadata if we have it.
[4454] Fix | Delete
$size_meta = $meta['sizes'][ $size ];
[4455] Fix | Delete
[4456] Fix | Delete
/*
[4457] Fix | Delete
* We have the actual image size, but might need to further constrain it if content_width is narrower.
[4458] Fix | Delete
* Thumbnail, medium, and full sizes are also checked against the site's height/width options.
[4459] Fix | Delete
*/
[4460] Fix | Delete
list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' );
[4461] Fix | Delete
[4462] Fix | Delete
$sizes[ $size ] = array(
[4463] Fix | Delete
'height' => $height,
[4464] Fix | Delete
'width' => $width,
[4465] Fix | Delete
'url' => $base_url . $size_meta['file'],
[4466] Fix | Delete
'orientation' => $height > $width ? 'portrait' : 'landscape',
[4467] Fix | Delete
);
[4468] Fix | Delete
}
[4469] Fix | Delete
}
[4470] Fix | Delete
[4471] Fix | Delete
if ( 'image' === $type ) {
[4472] Fix | Delete
if ( ! empty( $meta['original_image'] ) ) {
[4473] Fix | Delete
$response['originalImageURL'] = wp_get_original_image_url( $attachment->ID );
[4474] Fix | Delete
$response['originalImageName'] = wp_basename( wp_get_original_image_path( $attachment->ID ) );
[4475] Fix | Delete
}
[4476] Fix | Delete
[4477] Fix | Delete
$sizes['full'] = array( 'url' => $attachment_url );
[4478] Fix | Delete
[4479] Fix | Delete
if ( isset( $meta['height'], $meta['width'] ) ) {
[4480] Fix | Delete
$sizes['full']['height'] = $meta['height'];
[4481] Fix | Delete
$sizes['full']['width'] = $meta['width'];
[4482] Fix | Delete
$sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape';
[4483] Fix | Delete
}
[4484] Fix | Delete
[4485] Fix | Delete
$response = array_merge( $response, $sizes['full'] );
[4486] Fix | Delete
} elseif ( $meta['sizes']['full']['file'] ) {
[4487] Fix | Delete
$sizes['full'] = array(
[4488] Fix | Delete
'url' => $base_url . $meta['sizes']['full']['file'],
[4489] Fix | Delete
'height' => $meta['sizes']['full']['height'],
[4490] Fix | Delete
'width' => $meta['sizes']['full']['width'],
[4491] Fix | Delete
'orientation' => $meta['sizes']['full']['height'] > $meta['sizes']['full']['width'] ? 'portrait' : 'landscape',
[4492] Fix | Delete
);
[4493] Fix | Delete
}
[4494] Fix | Delete
[4495] Fix | Delete
$response = array_merge( $response, array( 'sizes' => $sizes ) );
[4496] Fix | Delete
}
[4497] Fix | Delete
[4498] Fix | Delete
if ( $meta && 'video' === $type ) {
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function