Help with Image Field control

Posted by Community Admin on 03-Aug-2018 16:01

Help with Image Field control

All Replies

Posted by Community Admin on 29-Nov-2013 00:00

Hello everyone,
I have an image field in a designer of Sitefinity widget. What I want to do is basically to get the selected image and hide the image field on change.
Is there such an event to attach to and hide the image field control?
Can anyone point me in the right direction?

Thanks,
Svetoslav Savov ,
The  eVeliko team.

Posted by Community Admin on 02-Dec-2013 00:00

Hi Svetoslav,

You could use for example JavaScript to hide the images:
- Add CSS class to the images, for instance 'MyClass'
- Add JavaScriptWidget on the page you need (choose option: 'Before the closing body tag' in order to
  get all the images on the page rendered)
- Add this code in the widget:

function hideImage()
  this.style.display = 'none';
 
var images = document.getElementsByClassName('MyClass');
  
for (i in images)
  var image = images[i];
  image.onclick = hideImage;
;

If this do not cover your needs, please describe more detailed your scenario.

Regards,
Svetoslav Manchev
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 04-Dec-2013 00:00

Hi Svetoslav, thanks for your response, but my problem is with the Image Field control.I will probably need to capture the event when the user selected another image, get it's url and change another image control to reflect the change.

Attached you should find screenshots that will hopefully help you get deeper in the problem.

Posted by Community Admin on 05-Dec-2013 00:00

Hi Svetoslav,

Could you please provide us more information about the control you are using and the scenario you have? Is this a custom one, created with Module builder or..? 

Please give us some code example or the entire control code that you are using.

Regards,
Svetoslav Manchev
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 23-Jan-2014 00:00

I want to use "on selected" or "image Change" event for ImageField, to set selected url to asp:Image and rebind ImageField without closing the designer.

Posted by Community Admin on 27-Jan-2014 00:00

Hi Svetoslav,

You could do this with JavaScript 
What I have tested:
- Create a widget with designer with image selector
- Add in the ascx file a new static img element

<img id="myImage" src="" alt="" />

- Update in the designer .js file:
jQuery("#previewMyImgSelector").load(function ()
            dialogBase.resizeToContent();
 
            // Implement your logic here:
             
            var selectorImgSrc = document.getElementById("previewMyImgSelector").src;
            var myImage = document.getElementById("myImage")
            myImage.src = selectorImgSrc;
 
        );

You could find a video demonstration how it works.

Regards,
Svetoslav Manchev
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 Public Issue Tracking system and vote to affect the priority of the items

This thread is closed