Database structure

Gallery3x1 min readPage 18 of 22
On this page 5

Four tables; the xPDO classes are in the Gallery3x\Model namespace. The component loads the package itself, so in your code $modx->getCollection(\Gallery3x\Model\Gallery3xFile::class, [...]) is enough.

TableClassWhat it stores
gallery3x_filesGallery3xFileImages
gallery3x_videosGallery3xVideoVideos
gallery3x_attachmentsGallery3xAttachmentFile attachments
gallery3x_embedsGallery3xEmbedEmbeds (maps, widgets, iframes)

All tables have id, resource_id (resource) and source_id (media source), plus common fields:

FieldTypeDescription
positionintOrder
groupvarcharGroups separated by ||
extra_text, extra_text2varcharExtra text fields
extra_numintExtra number
extra_datedatetimeExtra date
activetinyint1 — shown, 0 — disabled
createdon, updatedondatetimeCreated and updated dates
createdby, updatedbyintUser IDs

gallery3x_files

FieldTypeDescription
namevarcharTitle
alttextAlternative text
descriptiontextDescription (HTML)
pathvarcharFolder inside the source, e.g. 15/
filevarcharOriginal file name
type, sizevarchar, intMIME type and size in bytes
hashvarcharFile MD5
propertiestext (JSON)Thumbnail data: thumbnails.<size>.path etc.
specialtinyint“Special”
parent_idintReserved

gallery3x_videos

FieldTypeDescription
urltextVideo link
service, video_idvarcharService (youtube, rutube, vk, kinescope …) and the video ID there
title, descriptionvarchar, textTitle and description
thumbnailvarcharCover (path in the source)
specialtinyint“Special”

gallery3x_attachments

FieldTypeDescription
name, descriptionvarchar, textTitle and description
path, filevarcharFolder and file name
type, sizevarchar, intMIME type and size
hashvarcharFile MD5

gallery3x_embeds

FieldTypeDescription
title, descriptionvarchar, textTitle and description
modevarcharurl — by link, code — ready-made code
url, codetext, mediumtextSource link or embed code
provider, embed_idvarcharDetected service (yandex_map, google_map) and the final iframe URL
heightintHeight, px (empty — 400)
thumbnailvarcharPreview
specialtinyint“Special”

Example

$files = $modx->getCollection(\Gallery3x\Model\Gallery3xFile::class, [
    'resource_id' => 12,
    'active' => 1,
]);
foreach ($files as $file) {
    $thumbs = $file->get('properties')['thumbnails'] ?? [];
    echo $file->get('name'), ': ', $thumbs['small']['path'] ?? '', "\n";
}

Build URLs through the media source ($source->getBaseUrl() . path) or take ready ones from the snippets — paths in the database are relative.