简体   繁体   English

Laravel 4-刀片图像无法正确显示

[英]Laravel 4 - blade Images don't display properly

I experienced an issue displaying my images via Laravel blade templating. 我通过Laravel刀片模板显示图像时遇到问题。

In my "change-profile.blade.php" file I have a form that allows authenticated users to change some profile info. 在我的“ change-profile.blade.php”文件中,有一个表格,允许经过身份验证的用户更改某些个人资料信息。 In this specific case I want to display avatars based on gender input provided. 在这种情况下,我想根据提供的性别输入显示化身。

So far so good, my js works perfectly and my images url seems to be ok in terms of path. 到目前为止,到目前为止,我的js可以正常运行,并且我的图片网址在路径方面似乎还可以。 The problem is images result broken and I seriously don't know why. 问题是图像结果损坏了,我真的不知道为什么。 This is my code: 这是我的代码:

@extends('layout.main')
@section('content')
    <form action="{{ URL::route('profile-change-profile') }}" method="post">
        <fieldset class="change-profile">
            <legend>Change Profile</legend>
            <p>
                <input type="radio" class="gender" name="gender" value="male" /><span>male</span>
                <input type="radio" class="gender" name="gender" value="female" /><span>female</span> 
            </p>
            <p>
                <ul class="males gender">
                    @for ($i = 0; $i < 75; $i++)
                        <li><img src="{{ asset('assets/img/avatar/males/m-' . ($i+1) . '.png') }}" alt="avatar_male_{{ $i+1 }}"></li>
                    @endfor
                </ul>
                <ul class="females gender">
                    @for ($i = 0; $i < 40; $i++)
                        <li><img src="{{ asset('assets/img/avatar/females/f-' . ($i+1) . '.png') }}" alt="avatar_female_{{ $i+1 }}"></li>
                    @endfor
                </ul>
                <input type="hidden" class="avatar-src" name="avatar-src" value="" />
            </p>
            <p class="form-action">
                <button type="submit">submit</button>
                {{ Form::token() }}
            </p>
        </fieldset>
    </form>
@stop

My images are stored as png files in public/assets/img/avatar/(females|males)/(m|f)-n.png 我的图像以png文件格式存储在public / assets / img / avatar /(females | males)/(m | f)-n.png中

Any help? 有什么帮助吗?

Have you tried? 你有没有尝试过?

<li><img src="/assets/img/avatar/male/m-{{$i+1}}.png" alt="avatar_male_{{ $i+1 }}"></li>

<li><img src="/assets/img/avatar/females/f-{{$i+1}}.png" alt="avatar_female_{{ $i+1 }}"></li>

Solution found! 找到解决方案! It wasn't something wrong in my code but just folder encryption. 这不是我的代码中的问题,只是文件夹加密。 With folder encryption (due to zip folder or zip file saved on OSX) those files exist upon unzip process but they're not accessible (from a browser) until you disable the encryption itself manually. 使用文件夹加密(由于zip文件夹或OSX上保存的zip文件),这些文件在解压缩过程中存在,但是只有在手动禁用加密本身之后,才能访问这些文件(通过浏览器)。 You can avoid this annoying problem experienced on Windows just right-clicking on "green" filename/folder, select advanced and get rid of the tick related to encryption (last one tick, left-bottom). 您可以避免在Windows上遇到的烦人问题,只需右键单击“绿色”文件名/文件夹,选择“高级”并摆脱与加密相关的刻度(最后一个刻度,左下角)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM