DefaultContent with an Image

DefaultContent with an Image

mikedmasonmikedmason Posts: 36Questions: 11Answers: 0

Hi Guys,
Having a issue trying to get a dynamic image in the defaultcontent. I can hardcode a image src and it works but i want to use the field "image" that contains the image source. I am sure my syntax is wrong. Any help would be greatly appreciated.

Doesn't work

                            {
                              data: null,
                              defaultContent: '<img src="' + editor.field( 'image' ) + '" alt="./img/no-image-icon-15.png",width=60px, height=60px />',
                              orderable: false
                            },

Works

                                {
                                  data: null,
                                  defaultContent: '<img src="./uploads/32.png" alt="./img/no-image-icon-15.png",width=60px, height=60px />',
                                  orderable: false
                                },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 52,496Questions: 1Answers: 8,012 Site admin
    Answer ✓

    columns.defaultContent is for dynamic content only. Use columns.render if it needs to be dynamic (i.e. checking if there is a value from an Editor API method).

    Allan

  • mikedmasonmikedmason Posts: 36Questions: 11Answers: 0

    Thank you Alan. Read up and found this worked.

     {
                              data: null,
                              render: function(data,type,row){
                                    return '<img src="'+data.image+'",width=60px, height=60px />'},
                              orderable: false
                            }, 
    
This discussion has been closed.