• 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

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Installing Composer - Internal Error

Getting output of MS stored procedure on php call

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Google Calendar API batch request PHP

Only on Firefox "Loading failed for the <script> with source"

How to skip cart page on woocomerce for certain products only?

I want to display a sweetalert after the inserting of data in my database

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

PHP Download MP3 files from directory on server

curl returning 301 error after migrating to https

Search for array row with specific column value and return another value from qualifying row

How can I stop a symfony process which is listening on http://127.0.0.1:8000

Laravel get user data with profile

Sort multidimensional array by column value within a column

About Contact Privacy policy Terms and conditions