• 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

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

How to use React Router with Laravel?

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Why isn't my PHP exception working?

CodeIgniter extend CI_URI undefined method

Alert message after submitting form in PHP

HTML + PHP + PHPMAILER

Changing font color in javascript

"cannot list resources" error from WooCommerce REST API

How to get values inside <![CDATA[values]] > using php DOM?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

XSS attack still works despite htmlspecialchars() doing its work

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

About Contact Privacy policy Terms and conditions