November Happy Hour will be moved to Thursday December 5th.

New property in descendent of ImageData class does not appear in image edit pane in CMS

Jim
Jim
Vote:
 

I have a class called ImageMedia that is based on the ImageData class in EPiServer.Core.  There is a property, Description, which should be generating a text entry field when I edit an image in the Media tab but it's not showing up.  The code:

using System;
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.Framework.Blobs;
using EPiServer.Framework.DataAnnotations;

namespace ProQuest.Cms.Foundation.Media
{
    [ContentType(
        DisplayName = "Image Media",
        GUID = "b984ae67-63b6-4cd0-bf65-749ba4bd3526",
        Description = "Use this to upload image files.")]
    [MediaDescriptor(ExtensionString = "bmp,gif,jpg,jpeg,png,svg,tiff,ico")]
    public class ImageMedia : ImageData
    {
        [CultureSpecific]
        [Editable(true)]
        [Display(
            Name = "Alternate text",
            Description = "Description of the image",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual string Description { get; set; }

        public override Blob Thumbnail => BinaryData;
    }
}

A breakpoint set on the line that declares Description never stops the process, but a breakpoint on the line that declares Thumbnail does pause execution.  (PS  I did not write this code.)

#247599
Jan 25, 2021 16:10
Vote:
 

Hi Jim,

The property should appear by default. If not, then may be someone deleted that (from CMS admin) or your db version not reflecting the changes.

Are you also getting that issue locally (not seeing the property)?

You can try workaround like adding it manually from CMS admin and see if the value (after adding it manually) in your column From Code = Yes (last column in below image, it should not be missing value)

If you don't know, how to do that, you need to go into CMS > Admin > Content Type and select your type (should appear in Media Types group), then follow this document to add/update property (below link)

https://webhelp.episerver.com/latest/en/cms-admin/properties.htm

You can follow the information to add like Name, Description and other infomartion from your code (in screenshot you shared above).

Please let me know if have any futher issue. We can connect.

#247666
Jan 26, 2021 6:39
Vote:
 

Hi Jim,

A few questions first to narrow down what could be causing this:

  • is the issue only on your local environment? You said that content type is not writen by you, so assuming you have fteched the latest from your version control and it doesn't work
    • is the property visible in admin mode?
      • content types tab -> find the content type from the list and click it to see the properties for it
        • are there any property entries for the content type, that say missing or something else than yse in the "From code" column? 
    • are you using a local database or a shared database?
      • if shared database and you are using in episerver applicationSettings enableModelSyncCommit="false" then this might be the cause, so someone needs to sync the value to the shared database
    • clean you asp.net temp folder and web-project bin and then rebuild the solution
    • are you using IIS Express from Visual Studio of your local IIS
  • some other environment, like test, uat, prod, ...
    • but works in some of the environments?

Here is a link to blog post that explains the content model sync.

#247670
Edited, Jan 26, 2021 7:44
Vote:
 

Hi Jim,

I tried your code the property should appear with "Alternate text" as below, if you are looking the property name with Description, it will not be there(because of Display>Name) :

And if you still not able to find that property on page then as Praful said you need to confirm that property in your CMS>Admin under content Tab:

Hope it will helps you !

Thank you.

#247895
Jan 30, 2021 5:47
Vote:
 

Three suggestions:

  • Make sure you have not enableModelSyncCommit set to false in episerver.config
  • Locatate the content type in admin mode, click settings, revert to default and then save.
  • Check the logs for errors regarding content type synchroniztion
#247896
Edited, Jan 30, 2021 20:34
Jim
Vote:
 

Hi Praful, Antti, Sunil, and Tomas,

Thanks all for your quick responses.  The property was not appearing at all in Admin > Content Type > Image Media on my local server (IIS Express). I followed Praful's suggestion and added the property manually.  That worked and now the "Alternate text" field does appear in the Content tab.  👍

However, I set the Type to "String (<= 255)" and I get the error '"String (<= 255)" is not a valid value for "PropertyLongString".' when I save.  The Type can't be changed now.

  1. How do I know it's a "PropetyLongString" before I set the Type?  In the code, the property class is just "string".
  2. How do I know when I can use "String (<= 255)"?
  3. How do I change the Type (to "Long string (>255)") to fix it?

More details:

  • There were no content type synchronization errors in the logs.
  • I don't have access to Admin on the remote servers, only my local.
  • I can't locate the episerver.config file (That's pre-version 11, right?).  There is a web.config file, but it doesn't contain "enableModelSyncCommit" anywhere.

TIA,

Jim

#248348
Feb 08, 2021 16:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.