function dominant_attachment_save($attachment_id) { if (wp_attachment_is_image($attachment_id)) { $path = get_attached_file($attachment_id); $color = dominant_color($path); update_post_meta($attachment_id, 'dominant_color', $color); } }
else { asort($results); $results = array_keys($results); return $results[count($results)-1]; } } $colors = array( 'red' => array(255,0,0), 'orange' => array(255,127,0), 'yellow' => array(255,255,0), 'green' => array(0,255,0), 'blue' => array(0,0,255), 'purple' => array(127,0,255), 'pink' => array(255,0,255), ); */ if (isset($_GET['id_bille'])) { $id_bille = $_GET['id_bille']; $nom_image = 'IMAGES/MAIN/THUMBNAIL/' . $id_bille . '.jpg'; } else { $id_bille = 0; retournerErreur(400, 01, 'GET_JSON_BILLE_COLOR.PHP| Pas de référence de bille dans les données'); } $r_json = dominant_color($nom_image); echo json_encode($r_json, JSON_UNESCAPED_SLASHES); exit; ?>