Make Image Place Holder in Custom Block
Permalink
Hi
Wondering if someone can help or point me in the right direction...
I've used Designer Content to make a custom block.
One of the options I've worked in is to upload an image, though I haven't made it a required element.
If the site editor doesn't add an image, I would like the block to choose a default image in it's place once they add the block.
Any ideas?
Cheers! :)
PS - I'm not a php guru, just an html and css designer...
Wondering if someone can help or point me in the right direction...
I've used Designer Content to make a custom block.
One of the options I've worked in is to upload an image, though I haven't made it a required element.
If the site editor doesn't add an image, I would like the block to choose a default image in it's place once they add the block.
Any ideas?
Cheers! :)
PS - I'm not a php guru, just an html and css designer...
Thanks mnakaly,
My code I've got in the view looks a little different to yours.
I can't see a 'null' in my code. I've wrapped it in a div too.
My code:
My code I've got in the view looks a little different to yours.
I can't see a 'null' in my code. I've wrapped it in a div too.
My code:
Hi again,
I said in the controller not in the view. It is in the view function in the file controller.php not view.php
I said in the controller not in the view. It is in the view function in the file controller.php not view.php
Oh cheers friend... :)
In the controller created by Designer content, you can modify the view() function to do what you want.
In this example I have only one field and it's an image selector
You can modify it to be
What happened is that I replaced the null value with a function to get the default image. All you need to do is replace "default_image_id" with the id of the default image. You can find it in the file manager.