Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

How do i access different media types?

Started by Dean Bateman 5 years ago · 3 replies · 562 views
5 years ago

I am trying to access a glft file, which is a 3d format

I have added this to the media.yaml config

YAML
  glft:
    type: file
    thumb: media/thumb.png
    mime: application/json
    image: null

then added this to a template to access the file

TWIG
{% set my_model1 = page.media['Tripod Grip.gltf'] %}
{% set my_model2 = page.find('/images/3d-viewer').media['Tripod Grip.gltf'] %}

<text src="{{ my_model1 }}"></text>
<text src="{{ my_model2 }}"></text>

I have nominated two places to check if it makes a difference, but it returns src unknown.

i swapped the glft with searching for a png and it works so the code seems ok

is there anything else i need to do to enable grav to access different file types

5 years ago

@dean_007, Don't know the file format gltf, but when Googling a bit, I found:

TXT
mime: model/gltf+json

Maybe that works?

5 years ago

@pamtbaau:
model/gltf+json

i have just tried this but no change just comes back as empty / src unknown

5 years ago

ok stupid mistake, its a typo in the file ext ☺️

YAML
  gltf:
    type: gltf
    thumb: media/thumb.png
    mime: model/gltf+json
    image: null
TWIG
{% set my_model1 = page.media[page.header.model].url|e %} 
{% set my_model2 = page.find('/images/3dviewer').media[page.header.model].url|e %}

model 1 from page
model2 from images/3d viewer folder

last edited 07/01/21 by Dean Bateman

Suggested topics

Topic Participants Replies Views Activity
General · by jean-louis67, 3 days ago
2 81 2 days ago
General · by Andy Miller, 7 days ago
0 146 7 days ago
General · by Veehem, 1 week ago
0 145 1 week ago
General · by milkboy, 1 week ago
0 138 1 week ago
General · by ian russell, 2 weeks ago
2 226 2 weeks ago