Skip to content

Multi-Language & Media

When ProcessWire’s LanguageSupport module is active, Entries adds language tabs directly inside the form editor for any field marked useLanguages: true, with zero extra multi-language database tables.

Enable translations on text, slug, textarea, and richtext fields inside your blueprint:

site/entries/collections/seasons.yaml
fields:
title:
type: text
label: Season Name
required: true
index: true
useLanguages: true
inheritLanguage: true
summary:
type: textarea
label: Summary
useLanguages: true
inheritLanguage: false # Opt out of fallback when empty translations should stay blank

When inheritLanguage: true (the default):

  • Leaving a secondary language blank automatically falls back to the default language at runtime.
  • Entries pre-expands inherited values per lang_id in entries_index, so $entries->find() queries in secondary languages match inherited values with zero extra joins.

Reading, writing, and extracting localized text in PHP

Section titled “Reading, writing, and extracting localized text in PHP”
<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$languages = wire()->languages;
$season = $entries->findOne('type=seasons, code=HIGH_2026');
if ($season !== null) {
// Read in the active user's language
$season->of(true);
echo $sanitizer->entities((string) $season->get('title'));
// Shorthand setter by language name or ID
$season->of(false);
$season->setLocalized('title', 'tr', 'Yuksek Sezon (Temmuz - Agustos)');
// Or use ProcessWire's standard Language object API
if ($languages !== null) {
$tr = $languages->get('tr');
if ($tr && $tr->id) {
$season->setLanguageValue($tr, 'summary', 'Yaz donemi ozel tarifesi');
}
}
$entries->save($season);
// Extract plain text across all text fields for a locale (useful for search indexing or AI)
$plainProse = $season->plainText('tr');
}

Managed Tables also support translations on char, string, text, mediumtext, and longtext columns when useLanguages: true is set. Entries stores translations in a companion entries_tbl_<name>_i18n table (never created for single-language tables):

$rows = wire()->entries->tables()
->query('catalog_items')
->lang('tr')
->withTranslations()
->get();

Uploaded images and files live in site/assets/files/entries/{uuid}/, isolated from ProcessWire page asset directories and requiring zero ProcessWire field_* tables.

site/entries/collections/ports.yaml
fields:
cover_image:
type: image
label: Cover Image
extensions: 'jpg jpeg png webp'
maxFiles: 1
gallery:
type: image
label: Marina Gallery
extensions: 'jpg jpeg png webp'
maxFiles: 12
brochure:
type: file
label: Port Guide PDF
extensions: 'pdf'
maxFiles: 1

Rendering images (Pageimage and InterventionImage)

Section titled “Rendering images (Pageimage and InterventionImage)”

Output formatting controls how single-file fields (maxFiles: 1) unwrap:

  • When $item->of(false) (default in hooks, CLI, and modules), cover_image always returns a Pageimages collection.
  • When $item->of(true) (template rendering mode), maxFiles: 1 unwraps directly to ?Pageimage (or ?Pagefile).
site/templates/port.php
<?php
declare(strict_types=1);
namespace ProcessWire;
$port = wire()->entries->get('ports:gocek-marina');
if ($port !== null) {
// 1. Safe in any context (hooks, CLI, or templates)
$cover = $port->getUnformatted('cover_image')->first();
if ($cover !== null) {
$thumb = $cover->size(800, 600, ['upscaling' => false]);
$src = $sanitizer->entities($thumb->webp()->url);
$alt = $sanitizer->entities((string) ($cover->description ?: $port->get('title')));
echo "<img src=\"{$src}\" alt=\"{$alt}\" width=\"{$thumb->width}\" height=\"{$thumb->height}\" loading=\"lazy\">";
}
// 2. Formatted access (maxFiles: 1 unwraps to ?Pageimage)
$port->of(true);
if ($port->cover_image instanceof Pageimage) {
echo $port->cover_image->size(1200, 630)->url;
}
// 3. Multi-image gallery loop
foreach ($port->gallery as $image) {
$url = $sanitizer->entities($image->size(600, 400)->url);
echo "<img src=\"{$url}\" alt=\"{$sanitizer->entities((string) $image->description)}\">";
}
}

If InterventionImage (trk/intervention-image) is installed, wire()->image works directly with Pageimage objects returned by Entries.

Attaching files programmatically via PHP API

Section titled “Attaching files programmatically via PHP API”

Attach local files to an entry’s Pageimages or Pagefiles collection just like a standard ProcessWire Page:

<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$port = $entries->get('ports:gocek-marina');
if ($port !== null) {
$images = $port->getUnformatted('cover_image');
$images->add('/path/to/marina-aerial.jpg');
$images->last()->description = 'Aerial view of Gocek Marina';
$entries->save($port);
}

Next steps