[SOLVED] Media, Meta and how to make it easy for editors

I love the way, Grav handles meta-information for media. This has quite some potential. One major downside I have encountered so far is that editors are able to upload media to pages very easily. But they have to use FTP to upload meta.yaml-files to the same folder. Any workaround for that?

1 Like

You can take a look at this plugin, it was recently mentioned here as well…

Haven’t tried it myself, btw.

2 Likes

Thank you, @SjoerdSmeets! That was exactly what I was looking for! Issue solved, plain and simple.

1 Like

Good job, thanks for this.

If you’d like to create the yaml files only, you can use this batch script to scan the folder for image files and create the yaml file if the file doesn’t already exist.

test with a copy of your folder before testing on your final project.

copy the code below and save as meta-yaml.bat and change the default folder and follow the prompts.

@echo off
SETLOCAL

REM =========  VARIABLE  =========
SET "defaultdir=SET DEFAULT IMAGE FOLDER"
SET /a filecount = 0
SET /a pathset = 0
CLS

REM =========  MENU  =========
:CHOICE
ECHO.
ECHO 1. Set path same as batch location
ECHO 2. Set path same as default dir location
ECHO 3. Create files
ECHO 4. Exit
ECHO.

SET /P M=Select option by typing 1, 2, 3, or 4 then press ENTER:
IF %M%==1 GOTO :BATCH_LOCATION
IF %M%==2 GOTO :DEFAULT_LOCATION
IF %M%==3 GOTO :CREATE
IF %M%==4 GOTO :EOF

REM =========  SET LOCATIONS =========
:BATCH_LOCATION
SET /a "pathset=1"
SET targetdir=%~dp0
ECHO.
ECHO You selected this path: %targetdir:~0,-1%
ECHO.
goto :CHOICE

:DEFAULT_LOCATION
SET /a "pathset=1"
SET "targetdir=%defaultdir%"
ECHO.
ECHO You selected this path: %targetdir:~0,-1%
ECHO.
GOTO :CHOICE

REM =========  CREATE FILES =========
REM Use path to scan and create new yaml file if it doesnt exist

:CREATE
IF "%pathset%"=="0" (goto SETPATH)
ECHO.
FOR /R "%targetdir%" %%G in (*.png *.jpg *.jpeg *.gif) DO (
    SET /a "filecount+=1"
    IF EXIST %%G.meta.yaml (
	ECHO(Skipping File Exists    
    ) ELSE (
    	ECHO(Writing %%~nG.meta.yaml
    	>"%%G.meta.yaml" (
     	ECHO(title: %%~nG
     	ECHO(description:
    )
  )
)
ECHO.
ECHO(%filecount% files found
GOTO :EOF

REM =========  SET PATH WARNING =========

:SETPATH
ECHO.
ECHO WARNING, You must set a path first!
ECHO.
PAUSE
GOTO :CHOICE