express_entry_list: Calling an Image/File
Permalink 2 users found helpful
I am working on my custom listing (express_entry_list —> boats.php) with express objects from the example boat/marina.I have added an image as attribute in the form. I getting an error when calling an image. I am newbie, so I am sure I have the wrong syntax. Can someone please help?
<h1><?=$item->getEntry()->getBoatTitle();?></h1>
<p><?=$item->getEntry()->getBoatDescription();?></p>
<img src=“<?=$item->getEntry()->getBoatImage();?>” />
<h1><?=$item->getEntry()->getBoatTitle();?></h1>
<p><?=$item->getEntry()->getBoatDescription();?></p>
<img src=“<?=$item->getEntry()->getBoatImage();?>” />
Thank you MrKDilkington for your help!
Yes, exactly what you said, I am getting: "Object of class DoctrineProxies\__CG__\Concrete\Core\Entity\File\File could not be converted to string."
Could you point me to an example or right direction how to use the File class method to get the image's path?
Yes, exactly what you said, I am getting: "Object of class DoctrineProxies\__CG__\Concrete\Core\Entity\File\File could not be converted to string."
Could you point me to an example or right direction how to use the File class method to get the image's path?
@lukrecija
You can get the image file directly using getRelativePath().
You can resize or crop the image.
You can get the image file directly using getRelativePath().
You can resize or crop the image.
<?php $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); $boatImage = $item->getEntry()->getBoatImage(); if (is_object($boatImage)) { $imageHelper = $app->make('helper/image'); // getThumbnail($fileObject, maxWidth, maxHeight, crop) // - maxWidth and maxHeight are integers - setting them to "9999" effectively means "no maximum size" for that particular dimension // - crop set to true will crop the image // - crop set to false will not crop the image and preserve its dimension ratio // getThumbnail() creates an image object with these properties // - src // - width // - height // Example: // the image will not have a maximum width or maximum height
Viewing 15 lines of 40 lines. View entire code block.
@MrKDilkington
Totally worked! Thank you for taking the time to write this code for me!
Totally worked! Thank you for taking the time to write this code for me!
What is the error that you receive?
If getBoatImage() returns a file object (Concrete\Core\Entity\File\File) for the selected image/file, you will need to use a File class method to get the image's path. One way is to use getRelativePath().