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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How do i access different media types?

Started by Dean Bateman 5 years ago · 3 replies · 440 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 Jerry Hunt, 4 days ago
2 82 12 hours ago
General · by pamtbaau, 17 hours ago
1 55 16 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 348 5 days ago
General · by Duc , 5 days ago
3 43 5 days ago