• 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

Display the WooCommerce product price inside a custom function

Symfony 4: "Autowire: you should configure its value explicitly."

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

Clear javascript source cache laravel 5.8

Laravel Pagination links() not working

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

Insert multidimensional array to codeigniter cart

Filter WooCommerce related products by Polylang language

Create a zip file and download it

How to insert Google Adsense Code in PHP script?

PHP Discord OAUTH2 code sample not working

PHP: PDO + CSV export not downloading (headers issue?)

Get WooCommerce products from specific category

Cannot pass null argument when using type hinting

Can we define variables in `.tpl` files?

About Contact Privacy policy Terms and conditions