Blog Sections Open

Handling Babel and phpThumbOf Across Language Contexts

A practical pattern for rendering image TVs through phpThumbOf on multilingual Evolution CMS sites that use Babel-style context switching.

Multilingual Evolution CMS projects often run into image problems only after the frontend has been split into language contexts. A page may render correctly in one context and show a broken image in another, even though the TV value is present and the template markup looks fine.

The usual cause is not phpThumbOf itself. The real issue is that the resource query, the context mapping, or the TV include list does not line up with the language-aware structure of the site. Once the wrong resource is loaded, the image TV looks empty and phpThumbOf has nothing useful to transform.

Typical setup

A common pattern is to fetch the matching parent container for the active context and then render the image TV through a thumbnail modifier:

<img src="[[+tv.tv-hotel-img:phpthumbof=`w=380&h=600&zc=1`]]" alt="[[+pagetitle]]">

[[!pdoResources?
&parents=`[[*context_key:is=`web`:then=`1`:else=`[[*context_key:is=`de`:then=`5`:else=`4`]]`]]`
&tpl=`tpl.hotel-home`
&includeTVs=`tv-hotel-img,tv-hotel-info,tv-hotel-phone-1,tv-hotel-phone-2`
&showHidden=`1`
&sortby=`{"createdon":"ASC"}`]]

What to verify first

  • Make sure the query actually loads the resource from the correct language branch.
  • Confirm that the image TV is included in the resource call, not just in the template.
  • Check whether the stored TV value is a real image path in every language branch.
  • Test the raw TV output before applying phpThumbOf so you can see whether the source value is missing or only the thumbnail call is wrong.

Why phpThumbOn may appear to work differently

In some builds teams switch from phpThumbOf to another output modifier and assume the image issue is fixed. In reality the second modifier may simply be more forgiving about a partially valid path. It is still better to fix the context and data flow than to rely on a different thumbnail helper.

A safer debugging workflow

[[+tv.tv-hotel-img]]
[[+tv.tv-hotel-img:phpthumbof=`w=380&h=600&zc=1`]]

If the first line is empty, the problem is upstream: the wrong resource, wrong TV name, or missing TV data. If the first line is correct and the second fails, then focus on path handling, file existence, and thumbnail configuration.

Recommended approach

Keep the language branching logic as close as possible to the resource query, include the exact TVs you need, and test raw TV values before styling them. On Babel-style sites this usually solves the issue faster than replacing the thumbnail tool.

On larger Evo 1.4.x and Evo 3 sites the same rule still applies: the thumbnail layer should be the last step in the chain, not the place where you try to compensate for mismatched context data.

Newer post

Uploading Images Through eForm in Evolution CMS

A practical way to accept image uploads in eForm, move the file to a permanent location, and create a new Evolution CMS resource from the submitted data.

Older post

Generating a PDF from eForm Submission Data Before Sending Email

How to turn eForm field values into a styled PDF attachment and include it in the outgoing mail flow.