• 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

Smarty if isset

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

How to read laravel_session cookies saved in cookie memory of browser in client side?

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

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

How to separate letters and digits from a string in php

phpunit - testing is painfully slow

How to create a scheduler application in php

Yii2 redirecting to previous page after login

How to set a domain name with php artisan serve

XSS attack still works despite htmlspecialchars() doing its work

WHERE IN array binding in DB::raw laravel 5.4

Symfony there are no commands defined in the "make" namespace

Wordpress add responsive srcset header image to theme

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

About Contact Privacy policy Terms and conditions