skip to Main Content
        @foreach ($profiles as $profile)
        <tr>
            <td>{{ $profile->id }}</td>
            <td>{{ $profile->email }}</td>
            <td>{{ $profile->name }}</td>
            <td>{{ $profile->age }}</td>
            <td>{{ $profile->gender }}</td>
            <td>{{ $profile->position }}</td>
            <td>{{ $profile->department }}</td>
            <td>{{ $profile->phone_number }}</td>
            <td>
                @if ($profile->images)
   **             <img src="{{ asset('storage/app/public/'.$profile->images) }}" alt="Profile Image"
                    style="max-width: 50px; border-radius: 50%;">**
                @else
                No Image
                @endif
            </td>

I already try using URL in asset, but it didn’t work at all, I already make the storage folder short but it didn’t help me at all

3

Answers


  1. I don’t think you are linking it correctly with asset and prefix. try

    It will look for an image inside of a public/storage folder where you can define your own image folder

    <img src="{{ Storage::url($pathToImage) }}"
    
    Login or Signup to reply.
  2. please check below steps:

    1. Try save image location absolute instead of relative URL location in this case you should just put image URL location directive

      <img src="{{$profile->images}}" alt="Profile Image" style="max-width: 50px; border-radius: 50%;">
      
    2. if you want to save location in relative mode first of all check storage connect to your project or not
      in laravel you can use:

    php artisan storage:link

    in Linux you can use:

    ln -s /storagelocation public/storage

    and then use your code to show the img

    <img src="{{ asset('storage/app/public/'.$profile->images) }}"Alt="Profile Image" style="max-width: 50px; border-radius: 50%;">
    
    Login or Signup to reply.
  3. You can check these things:

    1. Check your .env file and APP_URL value: it should be https://[yourwebsite.com] – some people forget to change it from the default localhost or provide incorrect URL with an extra folder/subdomain
    2. If you store images in storage/app/public, check if you have run php artisan storage:link successfully (so, no errors happened) to create the symlink.
    3. Check if your web-server root folder is successfully pointed to the /public folder of the Laravel project.
    4. Then, you can call those storage/app/public images with asset('storage/'.$profile->images)

    Check the docs here: https://laravel.com/docs/10.x/filesystem#the-public-disk

    By the way, I would rename the variable from images to image, as it seems to be a single image and would likely be misunderstood by future developers.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search