Custom Image-Uploading FieldCancel

I'm new to sitefinity, so please help educate me if i'm saying something nonsensical!

So my goal is, specifically, to use a custom image uploader to help a user crop an image to a specific ratio, when adding or editing content with a module. I've got javascript on the client side that will do this. Swell.

Since i'm using the module for altering this content, i *think* i need a custom field to do it. I'd love to replicate the appearance and functionality of the default image uploader, and then modify what happens after an upload, or an image selection from the images that already exist. I went through the documentation here: http://www.sitefinity.com/documentation/gettingstarted/creating-custom-sitefinity-field-controls

It allowed me to successfully implement a simple text field. Good.

After that, i tried to add a MediaContentSelectorView to the ascx file. When i do that, i start getting null reference errors when i use the field and try to access instances of the module, specifically it's complaining that this.Container is null, where "this" is my class that inherits from FieldControl. It throws the exception during page load, in Telerik.Sitefinity.dll!Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Detail.SectionControl.FieldsRepeater_ItemDataBound

I'm just beating my head against the wall on this. Can anyone point me in the direction that will help me create a somewhat complex custom field?

I believe the easiest way for you to achieve your goal is to use an image selector. Please have a look at this blog post for information on how to implement it. From then on you can place it in a custom field and add your crop logic in either the designer or the control itself.

Regards,
Ivan D. Dimitrov
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items

1) Did you mean to include a link to a blog post? I can't see one in your post.

2) I attempted to use a MediaContentSelectorView (as per several posts here, here, here, and here) to select the image and then i wanted to intercept the image between form submission and database-saving. Whenever i included the mediacontentselectorview in my ascx file, i received a NullReferenceException stating that this.Container was null. Do you have any insight on why that is? I included it in the getscriptdescriptors section, and used the following markup:

3) Where would I intercept the value between form submission and database saving? I couldn't seem to find anything in the main .cs file that allowed me to access the just-submitted value (which is what i would need to do in my case, i believe - i can't do it all client-side). Basically the same question as here, but i don't see an answer in there.

However your last reply clarifies your scenario so I believe you will need to go through a different approach. Since you want to intercept the selected value of the created event you will need to attach to it from Sitefinity's event hub. Detailed information on this can be found in our Documentation. Unfortunately you will not be able to use client-side code in this scenario.

After you have attached to the event, you have access to all the field values and you can manipulate them in order to override the content saved in the database. You can find detailed in structions on our Related Data API in our Documentation. Basically you have two approaches. One is using the ContentLinksManager:

// At this point myCollection contains the items from type pressReleaseType

foreach (var item in myCollection)

{

var Data = item.GetRelatedItems("ImagesFrontend");

}

Once intercepted, you can alter the image field value (ImagesFrontend in my case) as per your criteria.

Regards,
Ivan D. Dimitrov
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items

Tools

Sitefinity Professional Services

Progress, Telerik, Sitefinity and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries.