Jump to content

[Resolved] Custom image fields error


Recommended Posts

Hello all,

I am creating a single custom image field as per the 3.0.142 post. However, when attempting to edit any image, I found the custom fields have been renamed. This also breaks any template code that tries to access those images. The field names have this pattern: title_fieldname_UUID, where title is the title field in the custom template, fieldname is the field name in the custom template, and UUID is a randomly generated ID.

The custom field entries in the database are correct, that is, page references, image name, image size, dimensions, etc., are all correct. All other field names (non-custom) on the page are correct (advanced mode on).

I see that other forum posts regarding custom image fields have not referenced my issue, so I assume it is pilot error except I don't see the current master version referenced elsewhere.

Ubuntu 18.04
PW 3.0.164 Master
PHP 7.2.24
Apache 2.4.29

Can someone provide more clues as to how I can track this down.

I appreciate your help.

Link to comment
Share on other sites

6 hours ago, rick said:

UUID is a randomly generated ID

Are you referring to the input names when you inspect them in your browser dev tools? It's normal for them to have that suffix - I expect it's to distinguish between inputs when there are multiple images in the same Page Edit form.

But you should still be able to access the custom image fields without any suffix. It's working for me - see screenshot:


Link to comment
Share on other sites

When editing an image (your colin-watts... pic) what does the field name display when you hover over the collapse toggle (on far right of field)?

Mine shows the name format I posted with the UUID. Does yours display only your field name?

Link to comment
Share on other sites

That is the problem. My field shows title_fieldname_UUID as the file name when I hover over the collapse toggle.

I've deleted the page, template, and field, then re-created a new one. The problem is persistent with every attempt.

If it works for you, but not for me, then I obviously have something configured incorrectly with my PW installation. I have no idea what that might be. ?


Link to comment
Share on other sites

I think this issue is one of those gotchas.


There are some visual glitches present, though they are pretty minor. For instance, clicking to open/collapse a field seems to briefly change the thumbnail size smaller, and then back again. I don't know why exactly, but there are some little things like that to work out still. Though I've already worked out a lot of them and don't think we have any left that will impede your ability to fully utilize these custom fields. Though do let me know if you find any showstoppers I might have missed, and I also appreciate any help in identfiying how to fix them as well.

I haven't located the area in the source where this field name is created. Any hint would be greatly appreciated.

Link to comment
Share on other sites

Could you please show the code you are using to access your custom image fields in your template file, and explain what error/problem happens when you try to do this?

I might be misunderstanding but it seems like you are getting hung up on the inputfield names in Page Edit when really you don't have to worry about these. You just access the custom fields from the Pageimage object using the names of the fields that you added to the template. So if you added the "title" field to the template that defines your custom image fields you access that field as $image->title, where $image is the Pageimage object from your image field.

The relevant part of the introductory blog post is:


Custom fields on file/image fields can be accessed the same way that they can be from a $page. So if you've added a "caption" field to your images field (like in my screenshot above) you could output it in the same way that you previously would have output a description. For example, below I'm going to output my images and include all my custom fields with it:

<?php foreach($page->images as $image): ?>
    <img src='<?=$image->url?>' alt='<?=$image->alt?>' />
      <?=$image->caption?> <br />
        Photographer: <?=$image->photographer?>,
        License: <?=$image->license->title?>
<?php endforeach; ?>


  • Like 2
Link to comment
Share on other sites

It appears that the upgrade to the latest stable version was corrupt. A clean install has it working again. Although I fail to see the reasoning behind having non-usable field names displayed while advanced mode is enabled. I don't recall if the prior version I was running had this "issue" because following the article example simply worked.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...