• 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

WordPress Subquery returns more than 1 row on SELECT

HTML + PHP + PHPMAILER

Lexik JWT authentication problem "Invalid credentials"

How to find the date a user created their Google account

Filter WooCommerce products with post__in and additional meta queries

Remove product downloads section in woocommerce email notifications

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

Laravel eloquent update record without loading from database

ConstraintViolationListInterface to Exception in Symfony

Detect if PHP session exists

Problem with fetching data from database in Laravel

LARAVEL: How to fetch id dynamically in a query builder?

Multiply each value in array using array_map function

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

About Contact Privacy policy Terms and conditions