Jump to content

Problems with formatted value of images


neonwired
 Share

Recommended Posts

@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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...