Jump to content

Recommended Posts

Posted

I'm having trouble with the formatted value of certain image fields. Regardless of what i select it always returns a PageImages object. Is this known to be buggy and is there a solution?

Posted

@neonwired Welcome. Please post your code otherwise it is difficult to help.
PageImages is a WireArray. Depending on your fieldsettings you maybe need to access a specific image as follows

$page->my_image_field->first() // first image of the field
$page->my_image_field->last() // last image of the field
$page->my_image_field->eq(4) // 5th image of the field

 

  • Like 1
Posted

Depends on where you're trying to use those values. Field values by default are only formatted while rendering templates. Otherwise (in hooks/modules) you'll most often get unformatted values, besides if they're called as part of the template rendering. If you want to be sure about things use these:

$page->getFormatted('fieldName');
$page->getUnformatted('fieldName');

The latter one is the most useful because it's independent on how fields are set up.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...