Level 2
You can try this:
<?php
$image = $news->image ? $news->image : 'default.jpeg';
$ogimg = 'https://naijaswift.com/image/' . $image
?>
1 like
I have this code
<?php
$ogimg = 'https://naijaswift.com/image/' . $news->image
?>
Which displays the Og:image from the image uploaded by the users for a post.
I would love to display the default site image on the og:image if the user(s) does not upload any image in post.
i.e if users uploads an image called go.jpeg it loads like this on og:image: https://example.com/image/go.jpeg but if the user does not upload any image in post it should be https://example.com/image/default.jpeg
You can try this:
<?php
$image = $news->image ? $news->image : 'default.jpeg';
$ogimg = 'https://naijaswift.com/image/' . $image
?>
Please or to participate in this conversation.