We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Auto-size of RTE image during upload

Thread ID:

Created:

Updated:

Platform:

Replies:

124967 Jul 11,2016 12:55 PM Jul 19,2016 11:10 AM JavaScript 3
loading
Tags: ejRTE
Randy Craven
Asked On July 11, 2016 12:55 PM

Hello,

When uploading an image to the RTE, I would like to set the width and height of the image, so that the entire image will be visible within the dimensions of the RTE .  I would prefer to do this programatically and not allow the user to set the dimensions.

Can anyone suggest a way to do this?

Thanks,
Randy Craven

Dhivyalakshmi Thirumurugan [Syncfusion]
Replied On July 12, 2016 01:20 AM

Hi Randy,   
   
Thanks for contacting Syncfusion support.   
  
We can resize the image by setting the height and width in the image dialog. For this we need to set the showDimensions property as trueand by default, the Constrain Proportion checkbox is selected to resize an image to an exact proportion. To apply the exact width and height that you specify into the Height and Width textboxes, uncheck the Constrain Proportions checkbox.  
 
Please find the code below.  
 
  $("#rteSample").ejRTE({   
  
                toolsList: ["images"],   
                tools: { images: ["image"] },   
                width: "100%",   
                minWidth: "150px",   
                showDimensions: true,   
                imageBrowser: { filePath: "http://mvc.syncfusion.com/OdataServices/FileBrowser/", ajaxAction: fileService, extensionAllow: "*.png, *.gif, *.jpg, *.jpeg, *.docx", ajaxSettings: ajaxSettings },   
                fileBrowser: { filePath: "http://mvc.syncfusion.com/OdataServices/FileBrowser/", ajaxAction: fileService, extensionAllow: "*.txt, *.png, *.pdf,*.jpeg", ajaxSettings: ajaxSettings1           }   
               
});   
  


 
We have prepared the sample as per your requirement and please find the sample below.  
 
 
Other References:  
 
   
Please let us know if you need any further assistance.   
   
Regards,   
Dhivyalakshmi.   


Randy Craven
Replied On July 18, 2016 07:13 PM

Hello Dhivyalakshmi,

Thank you for this information.

Is there a way to size the image without asking the user to enter anything?  For example: by determining the dimensions of the uploaded image and also the RTE 'viewport' and programmatically sizing the image to fit.

Can that be done?

Thank you again,
Randy

Keerthana Rajendran [Syncfusion]
Replied On July 19, 2016 11:10 AM

Hi Randy, 
Thank you for contacting Syncfusion support.  
We have prepared a sample based on our understanding by setting default height and width for images inserted into RTE in change event of RTE 
<code> 
function onchange() 
                            
                             $(".content-iframe").contents().find('img').css({'width':'200px','height':'200px'}); 
                              
                            
</code> 
 
We have prepared a sample for your reference. Please refer the below given link: 
If this doesn't match your requirement please get back to us with some more clear details on your query  
Regards, 
Keerthana 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;