Replace broken image icon if image element is null

vinia

Member
Hi.

Is it possible to replace the broken image icon when image element is missing. I would like to replace it with an image with text saying "image not available".

Thanks!
 
In which case, yes, you can override the image element layout.

http://fabrikar.com/forums/index.php?wiki/jlayouts/

So copy ./plugins/fabrik_element/image/layouts/fabrik-element-image-form.php to the location described in the wiki.

Then in the layout, $d->defaultImage is the URL to the image. You'll need to convert that to a path, and test to see if the file exists, and if it doesn't, change the $image ... so replace line 6 with ...

Code:
$imagePath = str_replace(COM_FABRIK_LIVESITE, COM_FABRIK_BASE, $d->defaultImage);
if (JFile::exists($imagePath)) :
   $image = '<img src="' . $d->defaultImage . '" alt="' . $d->value . '" ' . $d->float . ' class="imagedisplayor"/>';
else :
   $image = '<img src="http://yoursite.com/path/to/your/image.png" alt="Image not available" ' . $d->float . 'class=imagedisplayor"/>';
endif;

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top