This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I created a Model and Database and can upload an image in the Backend Columns using the Media Finder. But after uploading, no image path is saved to the database in the photo column.
I added $attachOne
to Model.
public $attachOne = [
'photo' => 'System\Models\File'
];
I set Media Finder field as photo
in fields.yamal
.
Database Tables
id
(integer)title
(string)photo
(string) (image path)
Twig
{% 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.
Last updated
The photo field in the database is not needed.
In the template, enter {{ product.photo.path }} or {{ product.photo.thumb(500,auto) }} etc.
It does not display the image.
In the backend, after I upload and go back to the entry, the photo is missing.
mailyura24071 said:
Watch the video
http://watch-learn.com/video-tutorials/making-websites-with-october-cms-part-09-images-and-galleries
I did all of that, it is not working. What am I missing?
1
Created Model, added:
public $attachOne = [
'photo' => 'System\Models\File'
];
2
Added Media Finder to fields.yamal
.
3
Set Field Name to photo
.
4
Upload image in backend using Media Finder. Uploads to media directory.
5
Save and Refresh, image is missing. Does not display with Twig. Path nowhere in database.
Last updated
mailyura24071 said:
Watch the video
http://watch-learn.com/video-tutorials/making-websites-with-october-cms-part-09-images-and-galleries
It looks like I got it solved.
I removed public $attachOne
and added photo
column to the database.
how to show that photo at frontend .i did all of that show in http://watch-learn.com/video-tutorials/making-websites-with-october-cms-part-09-images-and-galleries
this link but it not showing any path or whatever to say is printed after typing {{record.photo}}
and i am not using file upload instead of media finder
Last updated
Same issue.
If your image fiel is and upload field you've have to use
{{product.photo.path}}
or if it's a media finder
use this
{{product.photo}}|media
Remove this from your model:
public $attachOne = [ 'photo' => 'System\Models\File' ];
and crearte photo
field on your database table
- You can remove the code public $attachOne = [ 'photo' => 'System\Models\File' ]; from your plugin file.
- Add photo column of type String (Nullable) in your table This will work as normal.
1-10 of 10