Closed sime closed 11 years ago
I agree
There's a defaultPath
option that does something similar, good enough?
https://github.com/milesj/uploader/blob/master/Model/Behavior/AttachmentBehavior.php#L74
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.
Yeah agreed, never thought about using afterFind(). Could probably switch defaultPath
from storing to the DB to use afterFind() without any backwards compat problems.
Updated to use afterFind() instead, works well.
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?