Get&Store image id from file manager (image helper?)1 user found helpful
How can I get the image id from filemanager (using a button that opens filemanager and lets you choose an image).
I tried Image and file helpers but I think they save the image, not its id.
Thank you a lot,
Returns the ID of the file.
Look into image block controller and the anwser his there.
$alh = Loader::helper('concrete/asset_library'); echo $alh->image('selector_html_id', 'your_image_field_name', t('Select an image'), $selectedFileObject);
And that will show up the selector. After adding that, the selected file id is available in $_POST['your_image_field_name'] in your controller.
Note that I have no idea where, why and how you're going to be using this, so this just shows the basics of this. E.g. if using that in a block or view controller, you should use $this->post('your_image_field_name') instead of the $_POST array.
Then, it's possible to get the image id from the image selector?
Thank you a lot :)
PS: Sorry for my english.
<input type="hidden" name="your_image_field_name" value="123" />
And the 123 there will be the id of the selected image. You can use that straight in your controller (whether it's a block or single page controller) when you post your form where that image selector is included.
Again, I really know nothing about the case in question, so no idea on how you're trying to use it.
(Its for showing a logo in my theme site).
It gets the path, but I have problems showing the image... It may be a css problem.
If it doesn't, then you probably are not getting the path right. You should be using:
$imageFile = File::getByID(123); $relpath = $imageFile->getRelativePath();
And then in your view print the relpath into your image src.
Thank you :)