You are here

function resmushit_dashboard in reSmush.it image style optimizer 7

Same name and namespace in other branches
  1. 7.2 resmushit.inc \resmushit_dashboard()

Return value

string Information relevant to the reSmush.it module activity on this site.

1 string reference to 'resmushit_dashboard'
resmushit_menu in ./resmushit.module
Menu for this module.

File

./resmushit.inc, line 222
Additional functions.

Code

function resmushit_dashboard() {
  $result = '';
  $result .= t('<p><h2>reSmush.it module dashboard</h2>');
  $result .= '<p>' . t('' . l(t('reSmush.it'), 'https://www.resmush.it/', array(
    'external' => TRUE,
    'attributes' => array(
      'target' => '_blank',
    ),
  )) . ' is a free image optimalization API that seamlessly replaced the excellent but now defunct Yahoo Smush.it web service. It compresses the size of your images, making them and therefore your website significantly faster to load.');
  $result .= t('<p><h3>Image styles</h3>');
  $result .= '<p>' . t('Effect reSmush.it is currently used by the following image styles on this site:');
  $image_styles = image_styles();
  $configured_image_styles = array();
  foreach ($image_styles as $style) {
    foreach ($style['effects'] as $arr) {
      if ($arr['label'] == 'reSmush.it') {
        $configured_image_styles[$style['name']] = $style['label'];
        break;
      }
    }
  }
  $list_image_styles = array();
  foreach ($configured_image_styles as $key => $val) {
    $list_image_styles[] = l($val, '/admin/config/media/image-styles/edit/' . $key);
  }
  if (empty($list_image_styles)) {
    $list_image_styles[] = 'None yet. Configure them at ' . l(t('admin/config/media/image-styles'), '/admin/config/media/image-styles') . '.';
  }
  $result .= theme_item_list(array(
    'items' => $list_image_styles,
    'title' => '',
    //'List of image styles using the reSmush.it effect',
    'type' => 'ul',
    'attributes' => array(),
  ));
  $result .= t('<p><h3>Successes</h3>');
  $result .= '<p>' . t('Total number of successful optimalizations on this site: ' . variable_get('resmushit_total_successes', 0)) . '.';
  $result .= t('<p><h3>JPEG image quality</h3>');
  $result .= '<p>' . t('JPEG image quality is set to ' . variable_get('image_jpeg_quality', 75) . '. reSmush.it recommends a value of at least 92 (see ' . l(t('here'), 'https://www.resmush.it/api', array(
    'external' => TRUE,
    'attributes' => array(
      'target' => '_blank',
    ),
  )) . '). That you can change at ' . l(t('/admin/config/media/image-toolkit'), '/admin/config/media/image-toolkit') . '.');
  $result .= '<p><h3>' . t('Recent %logsize operations:', array(
    '%logsize' => variable_get('resmushit_log_size', RESMUSHIT_TIMEOUT),
  )) . '</h3>';
  $recent_optimalizations = variable_get('resmushit_recent_optimalizations', array());
  $recent_optimalizations = array_reverse($recent_optimalizations);

  // dpm($recent_optimalizations);
  if (!empty($recent_optimalizations)) {
    $result .= '<table>';
    $result .= '<tr>';
    $result .= '<th>#</th>';
    $result .= '<th>Time</th>';
    $result .= '<th>Image</th>';
    $result .= '<th>Result</th>';
    $result .= '<th>Original size</th>';
    $result .= '<th>Input size</th>';
    $result .= '<th>Output size</th>';
    $result .= '<th>Reduction in size</th>';
    $result .= '</tr>';
    foreach ($recent_optimalizations as $keyrow => $row) {
      $result .= '<tr>';
      $result .= '<td>' . ($keyrow + 1) . '.</td>';
      foreach ($row as $col) {
        $result .= '<td>';
        $result .= $col;
        $result .= '</td>';
      }
      $result .= '</tr>';
    }
    $result .= '</table>';
  }
  return $result;
}