Image/No image display help

cruser 21 Feb, 2022
I am having trouble getting this to work. The Read.itemdesc displays the item's description properly but for some reason, I cannot get the image to display. The image is in fact present on the server and I can only get the echo "No image".
<p>{var:Read.itemdesc}</p>

<center>
<?php
if ( !empty($this->get("{var:Read.itemdescphoto}")) ) {
echo "<img width='100%' src='components/com_chronoforms7/chronoforms/images/uploads/" . $this->get("{var:Read.itemdescphoto}") . "' />";
} else {
echo "No image";
}
?></center>
Colnem 21 Feb, 2022
Try echo "<img width='100%' src='/components/com_chronoforms7/chronoforms/images/uploads/"

Are you sure that your image is in ".../images/uploads/" ?
Because by default, the folder is "/components/com_chronoforms7/chronoforms/uploads/"...
cruser 21 Feb, 2022
You're right, Colnem. I did update that and still get "No image".
<?php
if ( !empty($this->get("{var:Read.itemdescphoto}")) ) {
echo "<img width='100%' src='/components/com_chronoforms7/chronoforms/uploads/" . $this->get("{var:Read.itemdescphoto}") . "' />";
} else {
echo "No image";
}
?></center>
Maybe there is still an error in my PHP? When I use this code, the image attached to its listing displays properly:
<img src="components/com_chronoforms7/chronoforms/uploads/{var:Read.itemdescphoto}">
cruser 21 Feb, 2022
The debug shows that the image is being found:
[itemdescphoto] => 20220215231459_tcop-01.jpg
cruser 21 Feb, 2022
I got it! Thanks for making me look a little harder, Colnem. The correct coding is below. I had to remove {var:}
<?php
if ( !empty($this->get("Read.itemdescphoto")) ) {
echo "<img width='100%' src='/components/com_chronoforms7/chronoforms/uploads/" . $this->get("Read.itemdescphoto") . "' />";
} else {
echo "No image";
}
?>
You need to login to be able to post a reply.