• 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

Hide specific products from unlogged users based in product category in WooCommerce

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Popup Window and PHP form

Magento 2 - How to add new block to admin panel in product page?

Laravel Route issues with Route order in web.php

Mysqli Output to a table

PHP/HTML: Creating A SubMenu

Unable to run composer install

Laravel get user data with profile

Insert a DIV after the 6th product only once in WooCommerce category archives

Add a custom text for a particular product on specific email notification in Woocommerce

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Phpunit partial mock + proxy Entity

how to use extended ASCII instead of unicode in PHP

About Contact Privacy policy Terms and conditions