First commit for dominant color core code#2906
Conversation
| * | ||
| * @return string|WP_Error Dominant hex color string, or an error on failure. | ||
| */ | ||
| public function get_dominant_color() { |
There was a problem hiding this comment.
Need to add these methods to the WP_Image_Editor class.
There was a problem hiding this comment.
These will both need to return WP_Error, with an a message saying these functions are not implemented.
There was a problem hiding this comment.
Second thoughts maybe this is not the best idea. Let look at WordPress/performance#404
| * @param int $attachment_id The attachment ID. | ||
| * @return array $metadata The attachment metadata. | ||
| */ | ||
| function dominant_color_metadata( $metadata, $attachment_id ) { |
There was a problem hiding this comment.
We can just add this directly there
There was a problem hiding this comment.
filter removed and calling function directly
| * @param object $attachment Image attachment post. | ||
| * @return mixed $attr Attributes for the image markup. | ||
| */ | ||
| function dominant_color_update_attachment_image_attributes( $attr, $attachment ) { |
There was a problem hiding this comment.
We can add these directly herer -
wordpress-develop/src/wp-includes/media.php
Line 1083 in f52d476
There was a problem hiding this comment.
filter removed and calling function directly
| * @param int $attachment_id The attachment ID. | ||
| * @return string image tag | ||
| */ | ||
| function dominant_color_img_tag_add_dominant_color( $filtered_image, $context, $attachment_id ) { |
There was a problem hiding this comment.
Let's not filter and manaully add this in here -
wordpress-develop/src/wp-includes/media.php
Line 1854 in f52d476
| */ | ||
| function _dominant_color_get_dominant_color_data( $attachment_id ) { | ||
| if ( ! wp_attachment_is_image( $attachment_id ) ) { | ||
| return new WP_Error( 'no_image_found', __( 'Unable to load image.', 'performance-lab' ) ); |
There was a problem hiding this comment.
Remove all the , 'performance-lab' references.
There was a problem hiding this comment.
Still seeing performance lab
| /** | ||
| * Get dominant color from a file. | ||
| * | ||
| * @since 1.2.0 |
There was a problem hiding this comment.
Change all references to 1.2.0 to 6.1
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
…-test.php Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
|
@pbearne Coding standard issues. |
| */ | ||
| function _dominant_color_get_dominant_color_data( $attachment_id ) { | ||
| if ( ! wp_attachment_is_image( $attachment_id ) ) { | ||
| return new WP_Error( 'no_image_found', __( 'Unable to load image.', 'performance-lab' ) ); |
There was a problem hiding this comment.
Still seeing performance lab
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
| * @param string $size Optional. Image size. Default 'thumbnail'. | ||
| * @return false|string Path to an image or false if not found. | ||
| */ | ||
| function wp_get_attachment_file_path( $attachment_id, $size = 'medium' ) { |
There was a problem hiding this comment.
Mismatch between default value for $size and the PHPDoc (medium vs thumbnail)
Fixed a mismatch between default value for $size and the PHPDoc (medium vs thumbnail)
reverted none related whitespace edit
revert whitespace edit
Trac ticket: https://core.trac.wordpress.org/ticket/56151