Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

How do i access different media types?

Started by Dean Bateman 5 years ago · 3 replies · 689 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 Andy Miller, 1 week ago
0 141 1 week ago
General · by lynbor, 1 month ago
3 457 2 weeks ago
General · by lynbor, 3 weeks ago
7 592 2 weeks ago
General · by Harry, 2 weeks ago
0 179 2 weeks ago
General · by Old Man Umby, 1 month ago
2 320 4 weeks ago