• 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 Display Data in Yajra Datatables Laravel 7?

Session timeout in Yii2

Store / Website Column in Magento 2 Admin Grid - Custom Module

Query Optimization, changing the queries in the loop into a single processing query

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

Store multiple fields in JSON column (Nova CMS)

how to redirect the user back to desired URL after login page in PHP?

json_encode turns array into an object

enroll_table three field fetch to payment form to create payment field in laravel 5.5

How to change product Image when variables are selected in Shop and Archive Pages?

AJAX call fails with SyntaxError: Unexpected end of JSON input

How to reset Laravel AuthManager/guards in between API calls in tests?

oauth-private.key does not exist or is not readable

php curl requesting twice

How do I remove this delivery notification from here?

About Contact Privacy policy Terms and conditions