DefaultContent with an Image

DefaultContent with an Image

mikedmasonmikedmason Posts: 39Questions: 12Answers: 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: 63,680Questions: 1Answers: 10,498 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: 39Questions: 12Answers: 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.