dotblue / nette-webimages

On-the-fly generated web images for your Nette app
Other
26 stars 17 forks source link

Optional path parameter #23

Closed Olicek closed 9 years ago

Olicek commented 9 years ago

I don't know if you find it interesting. I need it, so I just create pull request and maybe you find it usefull.

This PR add optional parameter path. It's because I use path like www\gallery\<name-of-gallery\300x200\photoId.jpg in my gallery folder. Well, the gallery name is set as 4th parameter (optional) in macro.

<img n:src="photoId, 300, 200, test-gallery">

In router I use then

- 'images/<path>/<width>x<height>/<id>.jpg'

What do you think?

vojtech-dobes commented 9 years ago

Well, the good news is that you can use this without any change in library :) (it's actually new feature in 2.0). You modified the library only in Macros class, and you can use custom <path> parameter without that change, like this:

<img n:src="photoId, 300, 200, path => test-gallery">
Olicek commented 9 years ago

Ok, that sounds great! Then, I would have a suggestion. What about that: the Macros implements some interface and by default would be used \DotBlue\WebImages\Macros. But somewhere (and I don't know where, maybe webimages: macros: MyClass) I would be able to use my own macro class. It can be more practical to overload default Macros class and use own prepareArguments. Something like this

class MyMacros extends DotBlue\WebImages\Macros
{
    public static function prepareArguments(array $arguments)
    {
        $arguments = parent::prepareArguments($arguments);
        // some my own magic 
        return $arguments;
    }
}

If I needed more parameters, It would be unpractical. Has it some negative impact to library work?

vysinsky commented 9 years ago

Well, you can override macro directly in latte. This does not make sense for me to have it in the library.