• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

I want to display default profile image if user do not have profile image

php


PHP Snippet 1:

if(!empty($path)){
  $path='<img src="/image/'.$image.'"/>';
} else {
  $path='<img src="/image/default.jpg"/>';
}

PHP Snippet 2:

<div>

  @if($user)
  <img src="{{ $user['user_avatar'] ? $user['user_avatar']:'default_profile_image' }}" alt="user image">

  @else
  <img src="default_profile_image" alt="user image">
  @endif

</div>

Related Snippets

How to reset Laravel AuthManager/guards in between API calls in tests?

Download & Save Zoom Recording in directory by PHP

Combine multiple columns into an array as one of the key in a results set

how to redirect the user back to desired URL after login page in PHP?

Changing font color in javascript

Laravel Multi-language routes without prefix

Send POST data via raw JSON with Postman

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Yii2: How do I debug console commands?

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

PHP each() function replacement

Sum array values of a column within each column of an array with 3 levels

If you intend you use SMTP, add your SMTP Code after this Line

Get sum of arrays inside array

args[max_input] woocommerce if statement confused

About Contact Privacy policy Terms and conditions