melinath / django-daguerre

On-the-fly image manipulation for Django.
http://django-daguerre.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
85 stars 15 forks source link

Add fallback handling to {% adjust %} template tag #8

Closed melinath closed 11 years ago

melinath commented 12 years ago

The {% adjust %} tag should behave more like sorl's {% thumbnail %} tag in that it should have an optional "empty" section which handles the case where something goes wrong.

melinath commented 11 years ago

Nah, we don't need this. You can already get this effect with as <varname> and if/else - plus, the if/else version works better with {% adjust_bulk %}

harrislapiroff commented 11 years ago

I do have some concern that if/else is not a very clear mechanism for error handling... Can we maybe add an error entry or something similar to the AdjustmentInfoDict so we can check explicitly for errors versus, like, a value never having been assigned in the first place?

melinath commented 11 years ago

What's the use case for recording the error?

harrislapiroff commented 11 years ago

I can imagine having a template where an image may or may not exist. I would like to have the ability to differentiate between the image not existing and daguerre having an error in adjusting it.

melinath commented 11 years ago

It seems like this could be useful for debugging purposes, but I'm still unclear on why the distinction would matter otherwise... in the template where the image may or may not exist, what would you do differently if the item didn't have an image versus if the image file was missing?

harrislapiroff commented 11 years ago

The situation I was imagining was a user uploading an image (say for their profile on a site) repeatedly and just getting "no image has been uploaded" repeatedly because there was some problem with Pillow or Daguerre. It would be better to either somehow say that there was an error and we're looking into (and therefore you do not need to keep uploading an image) or at least indicate that there is an image that was uploaded, even if it's not displaying. (Which cases, I suppose could be tested for by checking if the original image existed, but somehow that feels like extra steps to me.)

On Jun 16, 2013, at 12:44 PM, Stephen Burrows notifications@github.com wrote:

It seems like this could be useful for debugging purposes, but I'm still unclear on why the distinction would matter otherwise... in the template where the image may or may not exist, what would you do differently if the item didn't have an image versus if the image file was missing?

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

melinath commented 11 years ago

Daguerre only catches IOErrors (or their equivalents for other storage backends). In other words, it only catches errors caused by the file not existing (or not being a valid image). Any other problems in daguerre or pillow would cause a server error.

So I guess I'm still not convinced that this would be useful. I probably won't work on implementing it. But if there were a pull request, I wouldn't be averse to potentially merging it.

harrislapiroff commented 11 years ago

Fair enough. I'll give it some more thought.

On Sun, Jun 16, 2013 at 5:39 PM, Stephen Burrows notifications@github.comwrote:

Daguerre only catches IOErrors (or their equivalents for other storage backends). In other words, it only catches errors caused by the file not existing (or not being a valid image). Any other problems in daguerre or pillow would cause a server error.

So I guess I'm still not convinced that this would be useful. I probably won't work on implementing it. But if there were a pull request, I wouldn't be averse to potentially merging it.

— Reply to this email directly or view it on GitHubhttps://github.com/melinath/django-daguerre/issues/8#issuecomment-19519678 .