• 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 get unique slug to same post-title for other time too?

PHP drop down list using array's and foreach (else and for) code

(Laravel) How to delete multiple models including optional relationships?

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Create a zip file and download it

Get data from accuweather api url

Laravel 5.1 Unknown database type enum requested

Log file is not being written in Laravel 5.5

Laravel query builder binding parameters more than once

How to get Laravel's CSRF Token from Another Website?

How to create a individual template for page or post in custom plugin?

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

How can I access an array/object?

How to pass data to all views in Laravel 5?

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

About Contact Privacy policy Terms and conditions