milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Fallback image #147

Closed sime closed 11 years ago

sime commented 11 years ago

Background: I'm hacking up an AngularJS version of my views and noticed some logic in my CakePHP views which could be abstracted to the Model. Purely an idea at the moment.

In my View/Helper I check to see if an image is available prior to attempting to display it. If it's not available I'll render a static placeholder image.

Working on client side views, I see value in the Uploader.Attachment behavior having a fallbackImage setting. Reducing view logic. Potentially handled via an afterFind().

If no image exists and the column settings describes an fallbackImage, provide the fallbackImage as the actual result.

Sound sane?

josephzidell commented 11 years ago

I agree

milesj commented 11 years ago

There's a defaultPath option that does something similar, good enough?

https://github.com/milesj/uploader/blob/master/Model/Behavior/AttachmentBehavior.php#L74

sime commented 11 years ago

That's actually pretty good, though not for the use case I had in mind.

I have a dedicated model for attachements (User hasMany UserPhotos), and only touch it when I have something to upload.

Secondly I hesitate to enter 'placeholder' data into the DB.

milesj commented 11 years ago

Yeah agreed, never thought about using afterFind(). Could probably switch defaultPath from storing to the DB to use afterFind() without any backwards compat problems.

milesj commented 11 years ago

Updated to use afterFind() instead, works well.