• 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

Get WooCommerce products from specific category

Navigation idle on content download

Get lat/lon from google maps url ftid (hex)

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Woocommerce redirect after add-to-cart error

PHP array, move keys and values to new array, but mix it up

Detect emoticons in string

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Cache clear probem in Larave

WordPress - Dynamically add user ID to the end of a URL

How to change product Image when variables are selected in Shop and Archive Pages?

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Render the content of default_filter.php in Joomla front-end

Target class controller does not exist - Laravel 8

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

About Contact Privacy policy Terms and conditions