Giter VIP home page Giter VIP logo

sfimagetransformextraplugin's People

Contributors

caefer avatar gimler avatar robo47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sfimagetransformextraplugin's Issues

Override parameters

Hello,

i have a model with two images so i want override the slug parameter but i doesn't work.

sample code

url_for('sf_image', array('format' => 'frontend_large', 'sf_subject' => $event, 'attribute' => 'picture'));
url_for('sf_image', array('format' => 'frontend_large', 'sf_subject' => $event, 'attribute' => 'plan', 'slug' => 'plan'));

Mismatch in README and doctrine image functionality

The example given in the readme:

sf_image:
  class: sfImageTransformRoute
  url:   /thumbnails/:type/:format/:path/:slug-:id.:sf_format
  param: { module: sfImageTransformator, action: index, attribute: file }
  ...
  options:
    image_source: Doctrine

Within the sfImageSourceDoctrine, the path parameter seems to be ignored. If you look at the translated filepath, it seems the filepath is extracted from the class name instead:

sfConfig::get('sf_upload_dir').'/'.strtolower(get_class($obj)).'/'.$obj->$attribute

So it will work by accident if you use the path /uploads/modelname. The Propel source has a different implementation but still broken; the buildURIfromParameters seems to ignore the path in both.

Apologies for the crude format of this fix, but i found this to work for me (in sfImageSourceDoctrine). It also works in the case the developer just uses the root /uploads directory:

public static function buildURIfromParameters(array $parameters)
{
  ...

  $path = $parameters['attribute'];
  if (isset($parameters['path']))
  {
    $path = $parameters['path'] . '/' . $path;
  }
  return sprintf('sfImageSource://%s/%s#%s', $parameters['type'], $path, $parameters['id']);
}

protected function translatePathToFilename($path)
{
  ...
  $filepath = sfConfig::get('sf_upload_dir');
  $path = ltrim($url['path'], '/');
  $slashPos = strrpos($path, '/');
  $attribute = null;
  if ($slashPos === false)
  {
    $attribute = $path;
  }
  else
  {
    $attribute = substr($path, $slashPos + 1);
    $filepath .= '/' . substr($path, 0, $slashPos);
  }
  $filepath .= '/' . $obj->$attribute;
  return $filepath;
}

RecursiveDirectoryIterator::FOLLOW_SYMLINKS on php < 5.3

Hi,

It seems RecursiveDirectoryIterator::FOLLOW_SYMLINKS is available only with php > 5.3.
It would be great to fix that for other php version (5.2.x).
When submitted the form we got :

Fatal error: Undefined class constant 'FOLLOW_SYMLINKS' in .........plugins\sfImageTransformExtraPlugin\lib\cache\sfRawFileCache.class.php on line 104

I think a condition like that could save the problem

if (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS' ))

Jeremy

sfPearRest13

I try to install the plugin sfImageTransformExtraPlugin, but I have the error message: Class sfPearRest13 not found in ..../lib/vendor/symfony/lib/plugin/sfPearConfig.class.php on line 27. I work With Symfony 1.4.11.

Recursive image search can become problematic with same image name at further level of a directory tree

When more images with the same name are in a directory tree, the sfImageSourceFile class will find all images, not only the exact one.

An exemple will be certainly more explicit :

There is an image directory tree content exemple :
web/
uploads/
back.png
assets/
back.png

if i call the url "thumbnails/original/back.png", the rendered image isn't the "uploads/back.png" image, but the "uploads/assets/back.png"
Why ? Just because the way the sfImageSourceFile class found image is no much clear.
The problematic line is the following one :

$files = sfFinder::type('file')->name(array($file.'{.jpg,.png,.gif,.jpeg,}'))->in(sfConfig::get('sf_upload_dir').$path);

By default, sfFinder will search recursively in the given directory (check for the sfFinder::search_in() method, used by the sfFinder::in() method).
So, all file who is named 'back' in all directory tree under the given one will be founded by the sfFinder call.

A simplest solution is to add a maxdepth(0) call in the sfFinder construction, like this :

$files = sfFinder::type('file')->name(array($file.'{.jpg,.png,.gif,.jpeg,}'))->maxdepth(0)->in(sfConfig::get('sf_upload_dir').$path);

In this way, the file search will only search in the exact directory path, not all childrens.

A better way (more configurable) could be to add a configuration case who allow or forbidden deep search.

Incorrect yaml syntax in thumbnailing.yml

Lines 10, 11 and 12 :
- { adapter: GD, transformation: create, param: { x: 250, y: 200 } }}

- { adapter: GD, transformation: text, param: { text: '404', x: 10, y: 50, size: 72, font: accid___, color: '#FF0000', angle: 0 } }}

- { adapter: GD, transformation: text, param: { text: 'Image could not be found', x: 10, y: 120, size: 12, font: accid___, color: '#FF0000', angle: 0 } }}

The final ' } ' on each line looks wrong, no ?

Unable to save thumb if project is installed in subdirectory of web root

I have to say, this is a brilliant plugin.

After struggling a bit with why the plugin wouldn't save the generated thumbs, I found out it all lies in the sfRawFileCache.

When the method sfRawFileCache::setCacheKey calls $context->getController()->genUrl($internalUri, false), it will use the full public path, invalidating the internal path when the project is not installed in the document root.

I therefore propose to modify sfRawFileCache::setCacheKey() to look something like:

class sfRawFileCache extends sfFileCache
{
...
  static public function setCacheKey($internalUri, $hostName = '', $vary = '', $contextualPrefix = '', $sfViewCacheManager)
  {
    $context = sfContext::getInstance();
    $internalUri = str_replace('sfImageTransformator/index', '@'.$context->getRouting()->getCurrentRouteName(), $internalUri);

    return str_replace($context->getRequest()->getRelativeUrlRoot(), '', $context->getController()->genUrl($internalUri, false));
  }
...
}

ImageMagick support broken?

I am having trouble getting the ImageMagick adapter working via your plugin.

I believe it is because of your use of PHP stream paths, and that php5-imagemagick eventually boils down to raw executions outside of PHP, and thus the paths are unrecognised?

The error I'm getting in logs is:

unable to open image `/var/www/steve/web/sfImageSource:/Image/file#51'

As you can see it tries to append the stream URL to the end of the current execution path.

Am I doing something wrong or is the use of the adaptor in this way fundamentally flawed?

Error in image code due to web debug bar

Hi,

Yesterday, i have started to try the sfImageTransformExtraPlugin for my society.
First, i have to congratulate you for the work. Simple, fast, configurable and useful.

But, there is a little bug in the sfImageTransformator module.
I work on a development environment, where the debug is set on.

So, in the BasesfImageTransformatorActions->executeIndex() method, the web debug bar is rendered. Accordingly, the image is broken.

To correct this little bug, the solution is simpliest :

public function executeIndex(sfWebRequest $request) 
{
    sfConfig::set('sf_web_debug', false);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.