dimanche 27 septembre 2015

Laravel 5 and Codesleeve Stapler - Check if image exists

I currently have a fully working logo function, which adds a logo to the associated user, and then displays it. The only problem, is that even if a user hasn't uploaded a logo, it tries to display a "missing" one (which doesn't exist).

I would like to either:

  1. Check to see if a logo exists, if it does, display it.
  2. Have a default placeholder image (I have holder.js installed). I cannot find any documentation on adding default placeholders for missing logos though.

I've tried things like:

 @if($clinic->logo->url() !== null)

    <img src="<?= $clinic->logo->url('medium') ?>" alt="<?= $clinic->name ?>" 
              class="img-rounded col-md-12" style="padding-bottom: 20px;">

  @endif

But, the $clinic->logo->url() isn't null, in that sense, because it outputs - "/logos/original/missing.png".

Any help would be hugely appreciated



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KNuTwt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire