title: Laravel 5.4+ : Mutator/Accessor for uploaded image
body: <p>I'm trying to use mutator to store and retrieve users gravatar. </p>
  
  <p>In my User model I have :</p>
  
  <pre><code>public function getGravatarAttribute($gravatar){
      if($gravatar){
          $image = Storage::disk('local')-&gt;get('public/avatars/'.$gravatar.'.jpg');
          return new Response($image, 200);
      }
  
      $hash = md5(strtolower(trim($this-&gt;attributes['email'])));
      return "http://www.gravatar.com/avatar/$hash?s=256";
  }
  
  
  public function setGravatarAttribute($gravatar){
      if(is_object($gravatar) &amp;&amp; $gravatar-&gt;isValid()){
          $image = Image::make($gravatar)-&gt;fit(256, 256);
          Storage::disk('local')-&gt;put('public/avatars/'.$this-&gt;id . '.' . $gravatar-&gt;getClientOriginalExtension(),  $image-&gt;response());
          $this-&gt;attributes['gravatar'] = $this-&gt;id;
      }
  }
  </code></pre>
  
  <p>In the Blade file I do :</p>
  
  <pre><code>&lt;img id="avatar" src="{{ $user-&gt;gravatar }}" alt="your image" width="256" height="256"/&gt;
  </code></pre>
  
  <p>The mutator works nicely : the image is stored in the <code>storage/app/public/avatars</code> directory. The problem is the accessor : if I use a <code>dd($image);</code> before the return I can see the datas but it's not displayed in the html page</p>