Commit 234f2088 authored by ptmkenny's avatar ptmkenny Committed by jcisio
Browse files

Issue #2458453 by handrus, Plits, jsdix, rj, ptmkenny: Smush.it service has...

Issue #2458453 by handrus, Plits, jsdix, rj, ptmkenny: Smush.it service has changed so it is no longer available to the module
parent 9b75c24a
......@@ -37,3 +37,13 @@ function imageapi_optimize_update_7000() {
}
drupal_flush_all_caches();
}
/**
* If imageapi_optimize_service is set to 'smushit', change it to 'resmushit'
*/
function imageapi_optimize_update_7001() {
$var = variable_get('imageapi_optimize_service');
if ($var == 'smushit') {
variable_set('imageapi_optimize_service', 'resmushit');
}
}
<?php
/**
* @file
* Yahoo! Smush.it service integration.
* ReSmush.it service integration.
* Dedicated to old Yahoo Smush.it
*/
/**
* Implements imageapi_optimize_TYPE_NAME_info().
*/
function imageapi_optimize_services_smushit_info() {
function imageapi_optimize_services_resmushit_info() {
return array(
'title' => t('Yahoo! Smush.it'),
'url' => 'http://smush.it',
'title' => t('ReSmush.it'),
'url' => 'http://resmush.it',
);
}
/**
* Smush.it ImageAPI Optimize service callback.
*/
function imageapi_optimize_services_smushit($image, $dst) {
if (!function_exists('json_decode')) {
drupal_set_message(t('Required function, json_decode(), is not available.'), 'error');
return FALSE;
}
function imageapi_optimize_services_resmushit($image, $dst) {
$dst = drupal_realpath($dst);
$url = 'http://www.smushit.com/ysmush.it/ws.php';
$url = 'http://www.resmush.it/ws.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('files' => '@' . $dst));
if (!class_exists('CURLFile')) {
$arg = array('files' => '@' . $dst);
}
else {
$cfile = new CURLFile($dst);
$arg = array(
'files' => $cfile,
);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $arg);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
// SmushIt returns an error if it cannot optimize the image. Otherwise, it
// returns an object, with 'dest' (temporary file) and 'percent' (savings)
// among other properties.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment