• 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 trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Laravel 8: Array to string conversion while calling route:list

Navigation idle on content download

php code to send checkbox form results to email

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

PHP how to detect if running on arm64 cpu?

Match single unknown parameter php (Morse-code Regex)

Yii2: How to download backup files using spanjeta/yii2-backup?

PHP header location absolute URL

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

Return new collection without modifying original collection

Image upload not working through ajax Laravel

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

Installing Composer - Internal Error

Convert every two values of an associative array into key-value pairs

About Contact Privacy policy Terms and conditions