meenie / munee

Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation
https://munee.herokuapp.com/
MIT License
833 stars 92 forks source link

Default image when requested image not exists #17

Closed trizz closed 11 years ago

trizz commented 11 years ago

Hi,

When an image is requested and the source don't exists, is it possible to display a default image? I'm using Munee on a (custom) CDN for products but it isn't known if a product image already exists. Displaying a "No image yet" image is much nicer then showing nothing.

meenie commented 11 years ago

Hi @trizz,

This is actually undocumented at the moment which is really bad of me but this Gist should explain how you can do this.

https://gist.github.com/meenie/5193291

Please let me know if you run into any issues.

I'll just Close this for now, but please open it back up if you need to :).

Cheers, meenie

trizz commented 11 years ago

Wow! Quick response and perfect solution! Thank you!!

meenie commented 11 years ago

No worries :) - How have you found using Munee? Pretty easy? Have any issues installing it?

trizz commented 11 years ago

Well, I think that easier then Munee is kind of impossible. I mean, how hard is it to create the dispatcher and the .htaccess rule ;) It's pretty awesome that Munee handles everything. I don't need to worry recreating caches when I change my CSS or JS while I still profit from the speed of compressed CSS/JS. No issues installing it using Composer. Only thing I noticed is when I run composer update and there is an update for Munee, I get an error that the "cache" folder can't be removed (rights issue, the cache is created by the Apache user, while composer runs as another user). Just hacked this little script to solve that problem: https://gist.github.com/trizz/5728600. Executing that script from a browser (so the script runs as Apache user) removes the cache so Munee can be updated.

meenie commented 11 years ago

I'm glad to hear it :+1:. With regards to the cache, you can actually define MUNEE_CACHE before you include the Composer Autoload file and it will use that location to store the cache instead of inside the library itself. That way the cache doesn't have to be deleted when there is an update :).

Let me know if there is anything else you need or have any suggestions :).

Cheers, meenie

trizz commented 11 years ago

Unfortunately, MUNEE_CACHE isn't working...

define("MUNEE_CACHE", __DIR__.'/../cache/');
require '../vendor/autoload.php';

But my script still gives the following error: Error: The follow directory could not be made, please create it: /data/www/[domain_name]/vendor/meenie/munee/cache/JavaScript while the path I want is /data/www/[domain_name]/cache/JavaScript

dkcwd commented 11 years ago

Hi Tristan, sounds like a classic problem with file permissions.

If you are able to check and then set the file permissions for the relevant directory to allow the files to be written you should not receive any error.

Have you tried that already?

On 12/07/2013, at 18:01, Tristan notifications@github.com wrote:

Unfortunately, MUNEE_CACHE isn't working...

define("MUNEE_CACHE", DIR.'../cache/'); require '../vendor/autoload.php'; But my script still gives the following error: Error: The follow directory could not be made, please create it: /data/www/[domain_name]/vendor/meenie/munee/cache/JavaScript instead of Error: The follow directory could not be made, please create it: /data/www/[domain_name]/cache/JavaScript

— Reply to this email directly or view it on GitHub.

trizz commented 11 years ago

Yes, but the script references to the wrong cache dir :-) That is where the problem lies. The permission for /data/www/[domain_name]/cache is correct. For /data/www/[domain_name]/vendor/meenie/munee/cache/ I've set no write permissions, but I don't want to use that dir.

trizz commented 11 years ago

Never mind, got the wrong php file. I have defined the MUNEE_CACHE in my main index, not in the php file that handles the assets (and contains the dispatcher)

dkcwd commented 11 years ago

Ok mate, no worries :-)

On 12/07/2013, at 18:38, Tristan notifications@github.com wrote:

Nevermind, got the wrong php file. I have defined the MUNEE_CACHE in my main index, not in the php file that handles the assets (and contains the dispatcher)

— Reply to this email directly or view it on GitHub.