<!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>[BuddyPress][10178] trunk: Make sure uploaded images are oriented the right way.</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 { 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="http://buddypress.trac.wordpress.org/changeset/10178">10178</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10178","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-03 22:42:02 +0000 (Sat, 03 Oct 2015)</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'>Make sure uploaded images are oriented the right way.
When using a mobile device to set an avatar or a cover image, there are cases when the image can be saved upside down. We need to check the exif Orientation of uploaded images and rotate them if needed.
Introduce 2 new methods into the `BP_Attachment` class:
- `BP_Attachment->get_image_data()` to get an array of all image datas (including exif datas)
- `BP_Attachment->edit_image()` to edit the image orientation and/or resize the image.
Use these two new methods within the `BP_Attachment_Avatar->shrink()` and `BP_Attachment_Cover_Image()->fit()` methods.
Finally include a unit test for the `BP_Attachment->get_image_data()` method to check we get the orientation meta for all supported WorPress versions.
Props modemlooper, shanebp, r-a-y, DJPaul
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/5089">#5089</a>
See <a href="http://buddypress.trac.wordpress.org/ticket/6570">#6570</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcoreclassesclassbpattachmentavatarphp">trunk/src/bp-core/classes/class-bp-attachment-avatar.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpattachmentcoverimagephp">trunk/src/bp-core/classes/class-bp-attachment-cover-image.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpattachmentphp">trunk/src/bp-core/classes/class-bp-attachment.php</a></li>
<li><a href="#trunktestsphpunittestcasescoreclassbpattachmentphp">trunk/tests/phpunit/testcases/core/class-bp-attachment.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcoreclassesclassbpattachmentavatarphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-attachment-avatar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-attachment-avatar.php 2015-10-03 21:55:08 UTC (rev 10177)
+++ trunk/src/bp-core/classes/class-bp-attachment-avatar.php 2015-10-03 22:42:02 UTC (rev 10178)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,7 +119,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.3.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @uses bp_core_avatar_original_max_width()
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @uses wp_get_image_editor()
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file the absolute path to the file.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,39 +126,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function shrink( $file = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Get image size
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $size = @getimagesize( $file );
- $retval = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $avatar_data = parent::get_image_data( $file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check image size and shrink if too large
- if ( $size[0] > bp_core_avatar_original_max_width() ) {
- $editor = wp_get_image_editor( $file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Init the edit args
+ $edit_args = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_wp_error( $editor ) ) {
- $editor->set_quality( 100 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do we need to resize the image ?
+ if ( isset( $avatar_data['width'] ) && $avatar_data['width'] > bp_core_avatar_original_max_width() ) {
+ $edit_args = array(
+ 'max_w' => bp_core_avatar_original_max_width(),
+ 'max_h' => bp_core_avatar_original_max_width(),
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
- if ( ! is_wp_error( $resized ) ) {
- $thumb = $editor->save( $editor->generate_filename() );
- } else {
- $retval = $resized;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do we need to rotate the image ?
+ $angles = array(
+ 3 => 180,
+ 6 => -90,
+ 8 => 90,
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check for thumbnail creation errors
- if ( ( false === $retval ) && is_wp_error( $thumb ) ) {
- $retval = $thumb;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $avatar_data['meta']['orientation'] ) && isset( $angles[ $avatar_data['meta']['orientation'] ] ) ) {
+ $edit_args['rotate'] = $angles[ $avatar_data['meta']['orientation'] ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Thumbnail is good so proceed
- if ( false === $retval ) {
- $retval = $thumb;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No need to edit the avatar, original file will be used
+ if ( empty( $edit_args ) ) {
+ return 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">- } else {
- $retval = $editor;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add the file to the edit arguments
+ } else {
+ $edit_args['file'] = $file;
</ins><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">- return $retval;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return parent::edit_image( 'avatar', $edit_args );
</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="trunksrcbpcoreclassesclassbpattachmentcoverimagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-attachment-cover-image.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-attachment-cover-image.php 2015-10-03 21:55:08 UTC (rev 10177)
+++ trunk/src/bp-core/classes/class-bp-attachment-cover-image.php 2015-10-03 22:42:02 UTC (rev 10178)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -138,39 +138,52 @@
</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"> // Get image size
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $size = @getimagesize( $file );
- $retval = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cover_data = parent::get_image_data( $file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check image size and shrink if too large
- if ( $size[0] > $dimensions['width'] || $size[1] > $dimensions['height'] ) {
- $editor = wp_get_image_editor( $file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Init the edit args
+ $edit_args = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_wp_error( $editor ) ) {
- $editor->set_quality( 100 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do we need to resize the image ?
+ if ( ( isset( $cover_data['width'] ) && $cover_data['width'] > $dimensions['width'] ) ||
+ ( isset( $cover_data['height'] ) && $cover_data['height'] > $dimensions['height'] ) ) {
+ $edit_args = array(
+ 'max_w' => $dimensions['width'],
+ 'max_h' => $dimensions['height'],
+ 'crop' => true,
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $resized = $editor->resize( $dimensions['width'], $dimensions['height'], true );
- if ( ! is_wp_error( $resized ) ) {
- $cover = $editor->save( $this->generate_filename( $file ) );
- } else {
- $retval = $resized;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do we need to rotate the image ?
+ $angles = array(
+ 3 => 180,
+ 6 => -90,
+ 8 => 90,
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check for cover creation errors
- if ( ( false === $retval ) && is_wp_error( $cover ) ) {
- $retval = $cover;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $cover_data['meta']['orientation'] ) && isset( $angles[ $cover_data['meta']['orientation'] ] ) ) {
+ $edit_args['rotate'] = $angles[ $cover_data['meta']['orientation'] ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Cover is good so proceed
- if ( false === $retval ) {
- $retval = $cover;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // No need to edit the avatar, original file will be used
+ if ( empty( $edit_args ) ) {
+ return 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">- } else {
- $retval = $editor;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add the file to the edit arguments
+ } else {
+ $edit_args = array_merge( $edit_args, array( 'file' => $file, 'save' => false ) );
</ins><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">- return $retval;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Get the editor so that we can use a specific save method
+ $editor = parent::edit_image( 'cover_image', $edit_args );
+
+ if ( is_wp_error( $editor ) ) {
+ return $editor;
+ } elseif ( ! is_a( $editor, 'WP_Image_Editor' ) ) {
+ return false;
+ }
+
+ // Save the new image file
+ return $editor->save( $this->generate_filename( $file ) );
</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="trunksrcbpcoreclassesclassbpattachmentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-attachment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-attachment.php 2015-10-03 21:55:08 UTC (rev 10177)
+++ trunk/src/bp-core/classes/class-bp-attachment.php 2015-10-03 22:42:02 UTC (rev 10178)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -521,4 +521,142 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $script_data;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Get full data for an image
+ *
+ * @since 2.4.0
+ *
+ * @param string $file Absolute path to the uploaded image.
+ * @return bool|array An associate array containing the width, height and metadatas.
+ * False in case an important image attribute is missing.
+ */
+ public static function get_image_data( $file ) {
+ // Try to get image basic data
+ list( $width, $height, $sourceImageType ) = @getimagesize( $file );
+
+ // No need to carry on if we couldn't get image's basic data.
+ if ( is_null( $width ) || is_null( $height ) || is_null( $sourceImageType ) ) {
+ return false;
+ }
+
+ // Initialize the image data
+ $image_data = array(
+ 'width' => $width,
+ 'height' => $height,
+ );
+
+ /**
+ * Make sure the wp_read_image_metadata function is reachable for the old Avatar UI
+ * or if WordPress < 3.9 (New Avatar UI is not available in this case)
+ */
+ if ( ! function_exists( 'wp_read_image_metadata' ) ) {
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
+ }
+
+ // Now try to get image's meta data
+ $meta = wp_read_image_metadata( $file );
+
+ if ( ! empty( $meta ) ) {
+ // Before 4.0 the Orientation wasn't included
+ if ( ! isset( $meta['orientation'] ) &&
+ is_callable( 'exif_read_data' ) &&
+ in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) )
+ ) {
+ $exif = exif_read_data( $file );
+
+ if ( ! empty( $exif['Orientation'] ) ) {
+ $meta['orientation'] = $exif['Orientation'];
+ }
+ }
+
+ // Now add the metas to image data
+ $image_data['meta'] = $meta;
+ }
+
+ /**
+ * Filter here to add/remove/edit data to the image full data
+ *
+ * @since 2.4.0
+ *
+ * @param array $image_data An associate array containing the width, height and metadatas.
+ */
+ return apply_filters( 'bp_attachments_get_image_data', $image_data );
+ }
+
+ /**
+ * Edit an image file to resize it or rotate it
+ *
+ * @since 2.4.0
+ *
+ * @param string $attachment_type The attachment type (eg: avatar or cover_image). Required.
+ * @param array array $args {
+ * @type string $file Absolute path to the image file (required).
+ * @type int $max_w Max width attribute for the editor's resize method (optional).
+ * @type int $max_h Max height attribute for the editor's resize method (optional).
+ * @type bool $crop Crop attribute for the editor's resize method (optional).
+ * @type float $rotate Angle for the editor's rotate method (optional).
+ * @type int $quality Compression quality on a 1-100% scale (optional).
+ * @type bool $save Whether to use the editor's save method or not (optional).
+ * }
+ *
+ * @return string|WP_Image_Editor|WP_Error The edited image path or the WP_Image_Editor object in case of success,
+ * an WP_Error object otherwise.
+ */
+ public static function edit_image( $attachment_type, $args = array() ) {
+ if ( empty( $attachment_type ) ) {
+ return new WP_Error( 'missing_parameter' );
+ }
+
+ $r = bp_parse_args( $args, array(
+ 'file' => '',
+ 'max_w' => 0,
+ 'max_h' => 0,
+ 'crop' => false,
+ 'rotate' => 0,
+ 'quality' => 90,
+ 'save' => true,
+ ), 'attachment_' . $attachment_type . '_edit_image' );
+
+ // Make sure we have to edit the image.
+ if ( empty( $r['max_w'] ) && empty( $r['max_h'] ) && empty( $r['rotate'] ) && empty( $r['file'] ) ) {
+ return new WP_Error( 'missing_parameter' );
+ }
+
+ // Get the image editor
+ $editor = wp_get_image_editor( $r['file'] );
+
+ if ( is_wp_error( $editor ) ) {
+ return $editor;
+ }
+
+ $editor->set_quality( $r['quality'] );
+
+ if ( ! empty( $r['rotate'] ) ) {
+ $rotated = $editor->rotate( $r['rotate'] );
+
+ // Stop in case of error
+ if ( is_wp_error( $rotated ) ) {
+ return $rotated;
+ }
+ }
+
+ if ( ! empty( $r['max_w'] ) || ! empty( $r['max_h'] ) ) {
+ $resized = $editor->resize( $r['max_w'], $r['max_h'], $r['crop'] );
+
+ // Stop in case of error
+ if ( is_wp_error( $resized ) ) {
+ return $resized;
+ }
+ }
+
+ // Use the editor save method to get a path to the edited image
+ if ( true === $r['save'] ) {
+ return $editor->save( $editor->generate_filename() );
+
+ // Need to do some other edit actions or use a specific method to save file
+ } else {
+ return $editor;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestcasescoreclassbpattachmentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/core/class-bp-attachment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/core/class-bp-attachment.php 2015-10-03 21:55:08 UTC (rev 10177)
+++ trunk/tests/phpunit/testcases/core/class-bp-attachment.php 2015-10-03 22:42:02 UTC (rev 10178)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -443,4 +443,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Cleanup
</span><span class="cx" style="display: block; padding: 0 10px"> $this->clean_files( 'buddypress' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @group avatars
+ * @group cover_images
+ */
+ public function test_bp_attachment_get_image_data() {
+ $image_data = BP_Attachment::get_image_data( BP_TESTS_DIR . 'assets/upside-down.jpg' );
+
+ $this->assertTrue( 3 === $image_data['meta']['orientation'] );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>