<commit_before><?php

/**
 * This file is part of the sfImageHelper plugin.
 * (c) 2009 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfImageHelper.
 *
 * @package    OpenPNE
 * @subpackage helper
 * @author     <NAME> <<EMAIL>>
 */

/**
 * Returns a image tag for sfImageHandler.
 *
 * @param string $filename
 * @param array  $options
 *
 * @return string  An image tag.
 */
function image_tag_sf_image($filename, $options = array())
{
  if (empty($options['alt']))
  {
    $options['alt'] = '';
  }

  if (!$filename)
  {
    if (isset($options['no_image']))
    {
      $filename = $options['no_image'];
      unset($options['no_image']);
    }
    else
    {
      $filename = 'no_image.gif';
    }
    return image_tag($filename, $options);
  }

  $filepath = sf_image_path($filename, $options);
  if (isset($options['size']))
  {
    unset($options['size']);
  }
  if (isset($options['no_image']))
  {
    unset($options['no_image']);
  }

  return image_tag($filepath, $options);
}

function sf_image_path($filename, $options = array(), $absolute = false)
{
  if (isset($options['f']))
  {
    $f = $options['f'];
    unset($options['f']);
  }
 elseif (is_callable(array($filename, 'getType')))
  {
    $f = str_replace('image/', '', $filename->getType());
  }
  else
  {
    $parts = explode('_', $filename);
    $f = array_pop($parts);
  }

  if ($f !== 'jpg' && $f !== 'png' && $f !== 'gif')
  {
    $f = 'jpg';
  }

  $size = null;
  if (isset($options['size']))
  {
    $size = $options['size'];
    unset($options['size']);
  }

  $class = sfImageHandler::getStorageClassName();

  return  call_user_func(array($class, 'getUrlToImage'), $filename, $size, $f, $absolute);
}
<commit_msg>(fixes #1799) sfImageHandlerPlugin bug that does not correspond to the format options.<commit_after><?php

/**
 * This file is part of the sfImageHelper plugin.
 * (c) 2009 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfImageHelper.
 *
 * @package    OpenPNE
 * @subpackage helper
 * @author     <NAME> <<EMAIL>>
 */

/**
 * Returns a image tag for sfImageHandler.
 *
 * @param string $filename
 * @param array  $options
 *
 * @return string  An image tag.
 */
function image_tag_sf_image($filename, $options = array())
{
  if (empty($options['alt']))
  {
    $options['alt'] = '';
  }

  if (!$filename)
  {
    if (isset($options['no_image']))
    {
      $filename = $options['no_image'];
      unset($options['no_image']);
    }
    else
    {
      $filename = 'no_image.gif';
    }
    return image_tag($filename, $options);
  }

  $filepath = sf_image_path($filename, $options);
  if (isset($options['size']))
  {
    unset($options['size']);
  }
  if (isset($options['no_image']))
  {
    unset($options['no_image']);
  }
  if (isset($options['f']))
  {
    unset($options['f']);
  }
  if (isset($options['format']))
  {
    unset($options['format']);
  }

  return image_tag($filepath, $options);
}

function sf_image_path($filename, $options = array(), $absolute = false)
{
  if (isset($options['f']))
  {
    $f = $options['f'];
  }
  elseif (isset($options['format']))
  {
    $f = $options['format'];
  }
  elseif (is_callable(array($filename, 'getType')))
  {
    $f = str_replace('image/', '', $filename->getType());
  }
  else
  {
    $parts = explode('_', $filename);
    $f = array_pop($parts);
  }

  if ($f !== 'jpg' && $f !== 'png' && $f !== 'gif')
  {
    $f = 'jpg';
  }

  $size = null;
  if (isset($options['size']))
  {
    $size = $options['size'];
  }

  $class = sfImageHandler::getStorageClassName();

  return  call_user_func(array($class, 'getUrlToImage'), $filename, $size, $f, $absolute);
}

{'fraction_non_alphanumeric': 0.20072708387431837, 'fraction_numerical': 0.003116073747078681, 'mean_word_length': 3.3822525597269624, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6740756', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1336, 'n_words': 293}