Media Finder在前端显示图像 [英] Media Finder display Image on Front End

查看:77
本文介绍了Media Finder在前端显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个模型和数据库,可以使用Media Finder上传图像.

I created a Model and Database and can upload an image using the Media Finder.

我在fields.yamal中将Media Finder字段设置为photo.

I set Media Finder field as photo in fields.yamal.

但是,上传后,没有任何图像路径保存到照片"列中的数据库.

But after uploading, no image path is saved to the database in the photo column.

  • id(整数)
  • 标题(字符串)
  • 照片(字符串)
{% for product in builderListCatalog.records %}
    {{ product.title }}
    <img src="{{ product.photo }}" />
{% endfor %}

这将成功显示标题",但不会显示照片"路径,因为它在数据库中为空.

This successfully displays the Title but not the Photo path because it is empty in the database.

推荐答案

您需要删除添加到that field from model的所有关系.

You need to remove all the relation added to that field from model.

您正在使用public $attachOn 删除它是问题,现在将其视为文件附件关系不是查找程序图像,因此它不会在其中存储图像路径表中的photo (string)字段

You are using public $attachOn remove it that is the issue now its treated like file attachment relation not a finder image so it will not store path of image in that photo (string) field in table

如果使用media finder,则只需添加普通 > 表中的字段,而无需在模型中添加任何关联,它将仅存储在该字段例如. /someimage.png

If you use media finder you just need to add normal string (photo) field in table no need to add any relation in model and it will just store selected file path in that field for ex. /someimage.png

现在要在front-end中显示它,您可以使用

Now to show it in front-end you can use

<img src="{{ model.photo|media }}" />

在部分组件中,您可以使用

In component partial you can use

<img src="<?php echo 'https://october-plaza.com/storage/app/media/' . $model->photo ?>" />

如有疑问,请发表评论.

if any doubt please comment.

这篇关于Media Finder在前端显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆