• 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

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Artisan, creating tables in database

Yii Ajax Submit button

get folder directory from input type file - PHP

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Laravel Collections. Is there some kind of assertStructure method?

Check if user online laravel

Pages are working fine on localhost but not running on the hosting server

add uri parameter to Route name in laravel

Component install error: JInstaller: :Install: File does not exist

PHP Find Array Index value in multi-line array

CodeIgniter extend CI_URI undefined method

Problem with fetching data from database in Laravel

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

About Contact Privacy policy Terms and conditions