How to save asset library image object as a page attribute?
So I've been trying to replace a normal form image element with an image loader from the asset library to access some callback functions.
so I want to replace this ->
echo $akt->render('form', $tvalue, true);
with this ->
$al = Loader::helper('concrete/asset_library'); $al->image('ccm-b-image-'.$bID, 'thumbnail', t('Choose Image'), $bf);
The reason is, that I want to use the crop feature from the composer :
Unfortunately I am very unskilled in this field, so I need some help..
As mentioned I want to save my new $al into an attribute called "thumbnail", but here I am lost. How do I pass the file object to my controller with the rest of the form ?
I have pasted my view and my controller to get a hold of what's going on.. (the view has both the original form element and the al element right now when I am looking for a solution)
I really hope someone can tell me how to manage this, as I am very new to this :-)
$al->image('ccm-b-image-'.$bID, 'thumbnail', t('Choose Image'), $bf);
...is passing in the variable $bf, which is supposed to be an image object. But you haven't set that variable to actually be an image object. To get an image object, you call File::getByID(123) [where 123 is the file id].
It looks like you want the 'thumbnail' field to be the file id of the chosen image perhaps? If that's the case, then insert this new line of code above that other one:
In terms of learning how it works, I often find it helpful to see one piece of functionality isolated from everything else (so I can see what code is essential to that functionality working versus what's optional or what's related to something else entirely). If you want to do that, I'd suggest using Designer Content (http://www.concrete5.org/marketplace/addons/designer-content/... ) to generate a block with just one image field in it (and with no extra options on that field)... then look at the code it generates.