I am using a visualforce page to save a record which has a Name field and a rich text area type field in it. I am using inputfield tag to get the data from user and save the record. The user has the ability to add a picture of any height/width and save the record, but I would like to control this behavior and reduce the image height/width. How can I do that? Below is my VF page and extension of it:

<apex:page standardController="Warehouse__c" extensions="WarehouseExtension">

 <apex:form >
 <apex:commandButton value="Save" action="{!savePicture}"/>
 Image: <apex:inputfield value="{!Warehouse__c.Image__c}" rendered="{!status}"/>
<apex:outputfield value="{!Warehouse__c.Image__c}"  label="image" rendered="{!NOT(status)}"/>

<apex:image id="theImage" value="{!link}" width="300" height="200"/>

 Name: <apex:inputfield value="{!Warehouse__c.Name}"/>




public class WarehouseExtension {

    public Warehouse__c warehouse{get;set;}
    public boolean status{get;set;}
    ApexPages.StandardController stndcntrller{get;set;}
    public String link {get;set;}

    public WarehouseExtension(ApexPages.StandardController controller) {

    warehouse = (Warehouse__c)controller.getrecord();
    warehouse = [select image__c from Warehouse__c where id=:warehouse.id];

    String firstSubString = warehouse.Image__c.substringBetween('<img', 'img>');
    System.debug('First substring: ' + firstSubString);

    String secondSubString = firstSubString.substringBetween('src="', '"');
    System.debug('Second substring: ' + secondSubString);

    link = secondSubString.replace('amp;', '');
    link = '"'+link+'"';
    System.debug('Link: ' + link);

    status = Boolean.valueOf( ApexPages.currentPage().getParameters().get('status') );
    stndcntrller = controller;

    public Pagereference savePicture(){

    return null;


I tried putting style in inputfield but the image size does not change when the image is saved in the record.



You must log in to answer this question.

Browse other questions tagged .