• 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

Warning: sqlite_query() expects parameter 1 to be resource, string given

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Handle error for duplicate entries - PHP/MySQL

Not able to override collapsible.js in magento 2

CSV to PHP class properties

WooCommerce: Add/display Product or Variation custom field everywhere

Laravel 5.1 Unknown database type enum requested

How to validate tin and cst using PHP?

how to upload binary image to sql server using php laravel

mysql slow on updates for a well optimized query

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

Laravel 8: Array to string conversion while calling route:list

PHP SoapClient: set a namespace without prefix

Detect if PHP session exists

merging two arrays with specified index

About Contact Privacy policy Terms and conditions