Adding an image field to a custom module in 4.2
What's the best method for adding images to a custom module?
I've tried specifying the type of the backing field as a string and using the following as the backend editor:
var bSpotImage = new ImageFieldElement(bSpotSection.Fields)
ID = "bSpotImageField",
DataFieldName = "BSpotImage",
Title = "BSpot Image",
DisplayMode = displayMode,
CssClass = "sfFormSeparator sfContentField",
WrapperTag = HtmlTextWriterTag.Li,
FieldType = typeof(Telerik.Sitefinity.Web.UI.Fields.ImageField)
;
Hello,
If you are using Sitefinity 4.2.1650 there is a bug that is fixed in the hotfix for 4.1.1650. The bug was reducing the size of the image on upload
var productImageField =
new
ImageFieldElement(mainSection.Fields)
ID =
"avatarField"
,
DataFieldName =
"ProductImage"
,
DisplayMode = displayMode,
UploadMode = ImageFieldUploadMode.Dialog,
Title =
"ProductImageFieldTitle"
,
WrapperTag = HtmlTextWriterTag.Li,
CssClass =
"sfUserAvatar"
,
//specify your module resources here
ResourceClassId =
typeof
(ProductsResources).Name,
DataFieldType =
typeof
(ContentLink),
DefaultSrc =
"~/SFRes/images/ProductCatalogSample/Images.NoProductImage.png"
,
// put your default image location example if available, if not remove the line:
//this specifies the resizing during upload
SizeInPx = 100
;
I am running 4.2.1650. Can you provide a link to this hotfix?
Hi,
Excuse me I was mistaken the problem with images being resized was in Sitefinity 4.3.1873 and was fixed in 4.3.1885(the problem was when uploading an image with size 1mb displaying and downloading it returned an image of 200Kb which reduces quality).
In this case I suppose the problem in SizeInPx propery for the ImageFieldElement.
If this doesn`t help can you elaborate a little more about is the resize in image size in (Kb, Mb) or in size (pixels).
Both? It seems to be primarily a change in dimensions. I've outlined what I think are the important bits below.
From the Definitions:
var landingImage = new ImageFieldElement(landingSection.Fields)
ID = "landingImageUrl",
DataFieldName = "LandingImageUrl",
Title = "Landing Image Url",
DisplayMode = displayMode,
CssClass = "sfFormSeparator sfContentField",
WrapperTag = HtmlTextWriterTag.Li,
FieldType = typeof(Telerik.Sitefinity.Web.UI.Fields.ImageField),
SizeInPx = 448
;
landingSection.Fields.Add(landingImage);
[DataMember]
public string LandingImageUrl get; set;
public string LandingImageUrl get; set;
FYI, I've created a support ticket where you can find the source for the entire module.