• 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

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Reload parent page after submit in iframe

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Upgrade PHP on AWS Linux

What will the best solution for this multiple optional filter?

Shortcode or PHP inside a shortcode in Wordpress

Laravel Delete and Update

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

WHM Enabling mod_rewrite

dompdf and img tag, image wont show

AJAX call fails with SyntaxError: Unexpected end of JSON input

WHERE IN array binding in DB::raw laravel 5.4

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Laravel 8 Multiple Relationships for Factory

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

About Contact Privacy policy Terms and conditions