Text "Slides" in files section

Hi there,

my client wishes to have an image gallery with the media types images, video & text. I’m kind of stuck with which approach I should go.

A solution that’d work would be a structure field, but I kind of dislike the idea of having to select the images twice (uploading & then embedding in the structure). The most userfriendly way would be to create text-slides within the files section, that are sortable between the images and videos.

Buuuut I have no idea how to accomplish that. Might it be possible to choose between uploading or “creating” files in the panel? Could I bind that to a new filetype which simply has a textarea?

or maybe someone has a better idea? :slight_smile:

thanks in advance!


It looks as if you can upload .md (or other types of text files which are not .txt or .html) files if you use .txt for the content files. Downside to this approach is that you cannot preview the text unless you show a little excerpt in the info/text text (using a custom file method, you should be able to distinguish between images and text files for what sort of info is shown).

Custom file method example:

    'fileMethods' => [
        'getInfo' => function() {
            if ($this->mime() === 'text/plain') {
                return F::read($this);
            } else {
                return $this->niceSize();

In section definition:

        type: files
        layout: cards
        template: image
        info: "{{ file.getInfo }}"

For more control over what is shown (image or preview of the text), you could create a custom section.

1 Like

Thank you!!! this worked out pretty well. I tried creating a custom section but realised pretty quickly that this extends my abilities :wink:

Probably it’s easier to fetch the “caption” or anything similar from the rtf file, that makes it editable on the long run. As a bonus I’ll try to copy the text from the file to a the “caption” area on initial upload.

Thank you for your help and a good weekend, cheers

1 Like