• 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

Can't call javascript alert alertify library from PHP

Symfony Error: "An exception has been thrown during the rendering of a template"

Distribute array row data to make multiple new rows

I want a way to give path to my files which are outside of public folder in laravel

Laravel Nova, route not found

How to add a sidebar to Woocommerce Shop Page?

Laravel: Create morphs() relationship nullable

PHP -> Next nearest date defined by array of days in week

Laravel websockets AWS EC2 - Connection failed

How to Display Data in Yajra Datatables Laravel 7?

Custom add to cart button URL for specific product in WooCommerce?

How to give apache permission to write to home directory?

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

PHP DOTENV unable to load env vars

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

About Contact Privacy policy Terms and conditions