【问题标题】:Images not showing in blade.php file图像未显示在 Blade.php 文件中
【发布时间】:2020-11-25 05:35:59
【问题描述】:

我尝试在刀片文件中显示图像,但图像不显示,我写了正确的链接但仍然不显示 这是我的代码

  @if ($post->image == 'NULL')
  <!-- foto usahakan di crop 3x2 landscape-->
      <a href="{{ route('showpost', $post->slug) }}" class="mb-4 d block">
         <img style="width: 400px; height: 240px; overflow: hidden;"
            src="https://image.shutterstock.com/image-photo/white-transparent-leaf-on-mirror-260nw-1029171697.jpg" 
            alt="Image" class="img-fluid">
      </a>
  @else
      <a href="{{ route('showpost', $post->slug) }}" class="mb-4 d-block"> 
        <img style="width: 400px; height: 240px; overflow: hidden;" 
             src="{{ $post->image_url }}" alt="Image" class="img-fluid">
      </a>
  @endif

谁知道问题出在哪里?

【问题讨论】:

  • 需要更多信息。哪个没有显示。默认值应该可以工作。所以我假设你遇到的问题是动态 $post->image_url?转储 var 时会得到什么? {{dd($post-&gt;image)}}
  • 您的代码完美运行。刚刚检查了您在 {{$post->image}} 中得到的内容

标签: php html laravel laravel-blade


【解决方案1】:

如果您已经完成了 php artisan storage:link 命令,请在 src 中输入您的路径,例如 -:

<img style="width: 400px; height: 240px; overflow: hidden;" src="{{Storage::url('your_path/'.$post->image}}" alt="Image" class="img-fluid">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-13
    相关资源
    最近更新 更多