Display all the images in table cell from uploadmany plugin

Display all the images in table cell from uploadmany plugin

szotstihamerszotstihamer Posts: 1Questions: 1Answers: 0
edited July 2022 in Free community support

Hello,
I have a table and uploadmany with 2 uploaded images.

"files": {
"0_files": {
"92608": {
"id": "92608",
"filename": null,
"filesize": null,
"web_path": "/uploads/id1302.jpg",
"system_path": "/web/htdocs6/site/home/www/uploads/id1302.jpg"
},
"92609": {
"id": "92609",
"filename": null,
"filesize": null,
"web_path": "/uploads/id1302-1.jpg",
"system_path": "/web/htdocs6/site/home/www/uploads/id1302-1.jpg"
}
}
},

I can not figure out, how can I display the both web_path values in the table view.
The actual table view code looks like the below, but it only shows the count of the upladed photos.

        {
            data: "0_files",
            render: function ( d ) {
                return d.length ?
                    d.length+' image(s)' :
                    'No image';
            },
            title: "Image"
        },

I need an output like this:

<img src="/uploads/id1302.jpg" /><img src="/uploads/id1302-1.jpg" />

I have read all the documentation, but there is no example code of how to do this.
All I have found is that I have to loop through an array with for loop.
But the thread is solved and closed, but I really don't know how to do this.
Can someone explain it through an example?

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    edited July 2022

    I didn't test this but this might be close to what you need:

        render: function ( d ) {
            if ( d.length ) {
              var html = "";
              for ( i=0; i<d.length; i++ ) {
                html += '<img src="' + d[i].web_path + '" />';
              }
              return html;
            }
            return 'No image';
        },
    

    Kevin

Sign In or Register to comment.