<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55935] trunk: Media: Deprecate the 'edit_custom_thumbnail_sizes' filter and disable the "Apply changes to [Thumbnail|All|All except thumbnail]" UI in the image editor.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55935">55935</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55935","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-06-18 14:22:40 +0000 (Sun, 18 Jun 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Media: Deprecate the 'edit_custom_thumbnail_sizes' filter and disable the "Apply changes to [Thumbnail|All|All except thumbnail]" UI in the image editor. Add a (boolean) filter to reenable that UI.
Props peterwilsoncc, costdev, azaozz.
See: <a href="https://core.trac.wordpress.org/ticket/57685">#57685</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueueslibimageeditjs">trunk/src/js/_enqueues/lib/image-edit.js</a></li>
<li><a href="#trunksrcwpadminincludesimageeditphp">trunk/src/wp-admin/includes/image-edit.php</a></li>
<li><a href="#trunktestsphpunittestsajaxwpAjaxImageEditorphp">trunk/tests/phpunit/tests/ajax/wpAjaxImageEditor.php</a></li>
<li><a href="#trunktestsphpunittestsimagefunctionsphp">trunk/tests/phpunit/tests/image/functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueueslibimageeditjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/lib/image-edit.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/lib/image-edit.js 2023-06-18 12:53:47 UTC (rev 55934)
+++ trunk/src/js/_enqueues/lib/image-edit.js 2023-06-18 14:22:40 UTC (rev 55935)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -358,10 +358,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {number} postid The post ID.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {string} The value from the imagedit-save-target input field when available,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or 'full' when not available.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * 'full' when not selected, or 'all' if it doesn't exist.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- getTarget : function(postid) {
- return $('input[name="imgedit-target-' + postid + '"]:checked', '#imgedit-save-target-' + postid).val() || 'full';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ getTarget : function( postid ) {
+ var element = $( '#imgedit-save-target-' + postid );
+
+ if ( element.length ) {
+ return element.find( 'input[name="imgedit-target-' + postid + '"]:checked' ).val() || 'full';
+ }
+
+ return 'all';
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpadminincludesimageeditphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/image-edit.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/image-edit.php 2023-06-18 12:53:47 UTC (rev 55934)
+++ trunk/src/wp-admin/includes/image-edit.php 2023-06-18 14:22:40 UTC (rev 55935)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,15 +43,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $edit_custom_sizes = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Filters whether custom sizes are available options for image editing.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Shows the settings in the Image Editor that allow selecting to edit only the thumbnail of an image.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool|string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool Whether to show the settings in the Image Editor. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="imgedit-wrap wp-clearfix">
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="imgedit-panel-<?php echo $post_id; ?>">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -272,7 +273,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $thumb && $sub_sizes ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $edit_thumbnails_separately && $thumb && $sub_sizes ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,32 +308,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label>
</span><span class="cx" style="display: block; padding: 0 10px"> </span>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> <span class="imgedit-label">
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
</span><span class="cx" style="display: block; padding: 0 10px"> <label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label>
</span><span class="cx" style="display: block; padding: 0 10px"> </span>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php
- if ( $edit_custom_sizes ) {
- if ( ! is_array( $edit_custom_sizes ) ) {
- $edit_custom_sizes = get_intermediate_image_sizes();
- }
- foreach ( array_unique( $edit_custom_sizes ) as $key => $size ) {
- if ( array_key_exists( $size, $meta['sizes'] ) ) {
- if ( 'thumbnail' === $size ) {
- continue;
- }
- ?>
- <span class="imgedit-label">
- <input type="radio" id="imgedit-target-custom<?php echo esc_attr( $key ); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $size ); ?>" />
- <label for="imgedit-target-custom<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $size ); ?></label>
- </span>
- <?php
- }
- }
- }
- ?>
</del><span class="cx" style="display: block; padding: 0 10px"> </fieldset>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -918,6 +899,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** This filter is documented in wp-admin/includes/image-edit.php */
+ $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $scale ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $size = $img->get_size();
</span><span class="cx" style="display: block; padding: 0 10px"> $sX = $size['width'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -977,7 +961,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
</span><span class="cx" style="display: block; padding: 0 10px"> isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'thumbnail' === $target ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $new_path = "{$dirname}/{$filename}-temp.{$ext}";
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $new_path = $path;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1027,29 +1011,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $meta['width'] = $size['width'];
</span><span class="cx" style="display: block; padding: 0 10px"> $meta['height'] = $size['height'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $success ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $sizes = get_intermediate_image_sizes();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'nothumb' === $target || 'all' === $target ) {
- if ( 'nothumb' === $target ) {
- $sizes = array_diff( $sizes, array( 'thumbnail' ) );
- }
- } elseif ( 'thumbnail' !== $target ) {
- $sizes = array_diff( $sizes, array( $target ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( $edit_thumbnails_separately && 'nothumb' === $target ) {
+ $sizes = array_diff( $sizes, array( 'thumbnail' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $return->fw = $meta['width'];
</span><span class="cx" style="display: block; padding: 0 10px"> $return->fh = $meta['height'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( 'thumbnail' === $target ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $sizes = array( 'thumbnail' );
</span><span class="cx" style="display: block; padding: 0 10px"> $success = true;
</span><span class="cx" style="display: block; padding: 0 10px"> $delete = true;
</span><span class="cx" style="display: block; padding: 0 10px"> $nocrop = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- $sizes = array( $target );
- $success = true;
- $delete = true;
- $nocrop = $_wp_additional_image_sizes[ $size ]['crop'];
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span></span></pre></div>
<a id="trunktestsphpunittestsajaxwpAjaxImageEditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/ajax/wpAjaxImageEditor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/ajax/wpAjaxImageEditor.php 2023-06-18 12:53:47 UTC (rev 55934)
+++ trunk/tests/phpunit/tests/ajax/wpAjaxImageEditor.php 2023-06-18 14:22:40 UTC (rev 55935)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,39 +29,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 22985
- * @requires function imagejpeg
- *
- * @covers ::wp_insert_attachment
- * @covers ::wp_save_image
- */
- public function testCropImageThumbnail() {
- require_once ABSPATH . 'wp-admin/includes/image-edit.php';
-
- $filename = DIR_TESTDATA . '/images/canola.jpg';
- $contents = file_get_contents( $filename );
-
- $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
- $id = $this->_make_attachment( $upload );
-
- $_REQUEST['action'] = 'image-editor';
- $_REQUEST['context'] = 'edit-attachment';
- $_REQUEST['postid'] = $id;
- $_REQUEST['target'] = 'thumbnail';
- $_REQUEST['do'] = 'save';
- $_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":289,"h":322}}]';
-
- $media_meta = wp_get_attachment_metadata( $id );
- $this->assertArrayHasKey( 'sizes', $media_meta, 'attachment should have size data' );
- $this->assertArrayHasKey( 'medium', $media_meta['sizes'], 'attachment should have data for medium size' );
- $ret = wp_save_image( $id );
-
- $media_meta = wp_get_attachment_metadata( $id );
- $this->assertArrayHasKey( 'sizes', $media_meta, 'cropped attachment should have size data' );
- $this->assertArrayHasKey( 'medium', $media_meta['sizes'], 'cropped attachment should have data for medium size' );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @ticket 26381
</span><span class="cx" style="display: block; padding: 0 10px"> * @requires function imagejpeg
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre></div>
<a id="trunktestsphpunittestsimagefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/image/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/image/functions.php 2023-06-18 12:53:47 UTC (rev 55934)
+++ trunk/tests/phpunit/tests/image/functions.php 2023-06-18 14:22:40 UTC (rev 55935)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -351,6 +351,91 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests that `wp_image_editor()` applies 'image_edit_thumbnails_separately' filters.
+ *
+ * @ticket 53161
+ *
+ * @covers ::wp_image_editor
+ */
+ public function test_wp_image_editor_should_apply_image_edit_thumbnails_separately_filters() {
+ require_once ABSPATH . 'wp-admin/includes/image-edit.php';
+
+ $filename = DIR_TESTDATA . '/images/canola.jpg';
+ $contents = file_get_contents( $filename );
+ $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
+ $id = $this->_make_attachment( $upload );
+
+ $filter = new MockAction();
+ add_filter( 'image_edit_thumbnails_separately', array( &$filter, 'filter' ) );
+
+ ob_start();
+ wp_image_editor( $id );
+ ob_end_clean();
+
+ $this->assertSame( 1, $filter->get_call_count() );
+ }
+
+ /**
+ * Tests that `wp_image_editor()` conditionally outputs markup for editing thumbnails separately
+ * based on the result of applying 'image_edit_thumbnails_separately' filters.
+ *
+ * @ticket 53161
+ *
+ * @covers ::wp_image_editor
+ *
+ * @dataProvider data_wp_image_editor_should_respect_image_edit_thumbnails_separately_filters
+ *
+ * @param string $callback The name of the callback for the 'image_edit_thumbnails_separately' hook.
+ * @param bool $expected Whether the markup should be output.
+ */
+ public function test_wp_image_editor_should_respect_image_edit_thumbnails_separately_filters( $callback, $expected ) {
+ require_once ABSPATH . 'wp-admin/includes/image-edit.php';
+
+ $filename = DIR_TESTDATA . '/images/canola.jpg';
+ $contents = file_get_contents( $filename );
+ $upload = wp_upload_bits( wp_basename( $filename ), null, $contents );
+ $id = $this->_make_attachment( $upload );
+
+ add_filter( 'image_edit_thumbnails_separately', $callback );
+
+ ob_start();
+ wp_image_editor( $id );
+ $actual = ob_get_clean();
+
+ if ( $expected ) {
+ $this->assertStringContainsString(
+ 'imgedit-applyto',
+ $actual,
+ 'The markup should have been output.'
+ );
+ } else {
+ $this->assertStringNotContainsString(
+ 'imgedit-applyto',
+ $actual,
+ 'The markup should not have been output.'
+ );
+ }
+ }
+
+ /**
+ * Data provider.
+ *
+ * @return array[]
+ */
+ public function data_wp_image_editor_should_respect_image_edit_thumbnails_separately_filters() {
+ return array(
+ 'true' => array(
+ 'callback' => '__return_true',
+ 'expected' => true,
+ ),
+ 'false' => array(
+ 'callback' => '__return_false',
+ 'expected' => false,
+ ),
+ );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Tests that a passed mime type overrides the extension in the filename when saving an image.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @dataProvider data_image_editor_engine_classes
</span></span></pre>
</div>
</div>
</body>
</html>