Buy Licenses Contact Support Login/Register
v 1.7.7
v 1.7.7
Overview Examples Docs Source Download

Static Image

Add an image to your survey - Image element


                        
        
            Survey.StylesManager.applyTheme("default");
        


            
                var json = {
   "elements": [
    {
      "type": "image",
      "name": "banner",
      "imageLink": "https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg",
      "imageWidth": "500px",
      "imageHeight": "300px"
    }
   ]
};

                window.survey = new Survey.Model(json);
            
        
            survey.onComplete.add(function(result) {
            document.querySelector('#surveyResult').textContent =
            "Result JSON:\n" + JSON.stringify(result.data, null, 3);
            });
        
        
            $("#surveyElement").Survey({
            model: survey 
            });
        

                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Add an image to your survey - Image element, jQuery Survey Library Example</title>

<meta name="viewport" content="width=device-width" />
    <script src="https://unpkg.com/jquery"></script>
<script src="https://surveyjs.azureedge.net/1.7.7/survey.jquery.js"></script>
<link href="https://surveyjs.azureedge.net/1.7.7/survey.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">

</head>
<body>
    
            <div id="surveyElement" style="display:inline-block;width:100%;">
            </div>
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>

</body>
</html>
settings

survey.getQuestionByName('banner').imageHeight; survey.render();

survey.getQuestionByName('banner').imageWidth; survey.render();

Image fit mode: (default is 'contain')

var q = survey.getQuestionByName('banner');
q.imageFit = yourValue; 
survey.render();

Content mode : (default is 'image')

var q = survey.getQuestionByName('banner');
q.contentMode = yourValue; 
survey.render();