How to get the URL of a Page header image

Lennard van Diggelen asked on September 8, 2016 13:38

Hi there,

I've some trouble with getting the page header image that has been set on the page and I don't follow the concept of this element. I've added a page header image as you can see below but the database is still showing null as value. Where is this file stored and how can I get this value to use within my template files? And why is it possible to store multiple images instead of one like the Teaser image.

Image Text

Image Text



Recent Answers

Richard Sustek answered on September 8, 2016 15:21 (last edited on September 8, 2016 15:22)

This is really good question. The Attachments form control is quite specific because it needs to store multiple attachment GUIDs. These attachments are eventually stored in CMS_Attachment table and are linked to your page and field using the AttachmentDocumentID and AttachmentGroupGUID (points to guid of field where your attachments are stored) columns.

There is unfortunately to easy/built-in way how you could retrieve these attachments. What I would recommend to do is to create your own transformation method or macro that will programatically get these attachments so that you can work with them.

Following method will get you the attachments programatically:

public ObjectQuery<AttachmentInfo> GetAttachmentsFromField(string className, int documentID, string attachmentColumnName)
    // get class info       
    var classInfo = new FormInfo(DataClassInfoProvider.GetDataClassInfo(className).ClassFormDefinition);
    if (classInfo != null)
        // get attachment field definition            
        var attachmentsField = classInfo.GetFormField(attachmentColumnName);
        if (attachmentsField != null)
            // get attachments strored in the field by GUID
            var attachments = AttachmentInfoProvider.GetAttachments()
                .WhereEquals("3CCC6E6C-56F3-42EB-8385-979973D99C55", attachmentsField.Guid)
                .WhereEquals("AttachmentDocumentID", documentID);

            return attachments;
    return null;

And call it like:

string className = ""; // your page type class       
string attachmentFieldColumnName = "MultipleAttachments"; // column name of document attachment control field        
int documentID = 26; // test document where attachments are created

var attachments = GetAttachmentsFromField(className, documentID, attachmentFieldColumnName);
0 votesVote for this answer Mark as a Correct answer

Lennard van Diggelen answered on September 11, 2016 18:51

Hi Richard,

Sorry for the late response!

Thank you for the explanation. It makes more sense now! However the current functionality does not work for me because I need it with the same functionality as the teaser image.

I've changed the field for pageHeaderImage to the same as the teaser so now it is possible to set the image and a GUID appears in the table. I was wondering if I can get this guid easily by using a token or do I need to write a function again like the attachments? Can you help me with this challenge?

Hope to hear form you!


0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.