Basically if a variable isn't set then set it to another value.
There must be a better way, this looks so messy.
if ($image_src === undefined) {
$image_src = $apple_icon;
}
if ($image_src === undefined) {
$image_src = $apple_icon2;
}
if ($image_src === undefined) {
$image_src = $item_prop_image;
}
if ($image_src === undefined) {
$image_src = $image_first;
}
In JavaScript you can use the or ||
operator to condense things that are undefined. So this is valid:
$image_src = $image_src || $apple_icon || $apple_icon1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With