Making WordPress.org

Changeset 14358


Ignore:
Timestamp:
01/13/2025 07:42:49 PM (19 months ago)
Author:
coffee2code
Message:

Photo Directory, Vision API: Prevent error if no image properties were returned.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/google-vision-api.php

    r11679 r14358  
    141141                $results = [];
    142142
    143                 $colors = self::extract_colors( $response->imageProperties()->info()['dominantColors']['colors'] );
    144                 if ( $colors ) {
    145                         $results['vision_raw_colors'] = $colors[0];
    146                         $results['vision_colors']     = $colors[1];
     143                // Extract colors.
     144                $image_properties = $response->imageProperties();
     145                if ( $image_properties ) {
     146                        $raw_colors = $image_properties->info()['dominantColors']['colors'] ?? [];
     147                        if ( $raw_colors ) {
     148                                $colors = self::extract_colors( $raw_colors );
     149                                $results['vision_raw_colors'] = $colors[0];
     150                                $results['vision_colors']     = $colors[1];
     151                        }
    147152                }
    148153
Note: See TracChangeset for help on using the changeset viewer.