I need your help, I have a manager table, which I need to show the default photo when I am a new user, in my case I have a manager with a photo and another with a new manager, in the new one the default photo should be seen
In my code I am inserting an if so that it validates the photo that it adds in the database, it shows it if it exists, and if it doesn't, it shows the default one.
var mostrarDirectivos = function() {
var tableDirectivo = $('#dataTableDirectivo').DataTable({
"processing": true,
"serverSide": false,
"ajax": {
"url": "<?php echo constant('URL'); ?>directivo/readtable"
},
"columns": [{
defaultContent: "",
'render': function(data, type, JsonResultRow, meta) {
var fullnameImagen = JsonResultRow.appaterno_director + '_' + JsonResultRow.apmaterno_director + '_' + JsonResultRow.nombre_director + '/' + JsonResultRow.foto_director;
var img = '<?php echo constant('URL'); ?>public/director/';
if(img == null){
var fullnameImagen = JsonResultRow.appaterno_director + '_' + JsonResultRow.apmaterno_director + '_' + JsonResultRow.nombre_director + '/' + JsonResultRow.foto_director;
if(!file_exists(img)){
var img = '<?php echo constant('URL'); ?>public/director/';
}else{
var img = JsonResultRow.appaterno_director + '_' + JsonResultRow.apmaterno_director + '_' + JsonResultRow.nombre_director + '/' + JsonResultRow.foto_director;
}
}else{
var img = '<?php echo constant('URL'); ?>public/img/default.jpg';
return '<center><img src="' + img + '" class="rounded-circle img-fluid " style="width: 50px; height: 50px;"/></center>';
}
}
},
{
defaultContent: "",
"render": function(data, type, full) {
return full['nombre_director'] + ' ' + full['appaterno_director'] + ' ' + full['apmaterno_director'];
}
},
{
"data": "telefono_director"
},
{
"data": "cedulaprofesional_director"
},
{
data: null,
"defaultContent": `<button class='consulta btn btn-primary' data-toggle='modal' data-target='#modalDetalleDirectivo' title="Ver Detalles"><i class="fa fa-eye"></i></button>
<button class='editar btn btn-warning' data-toggle='modal' data-target='#modalActualizarDirectivo' title="Editar Datos"><i class="fa fa-edit"></i></button>
<button class='eliminar btn btn-danger' data-toggle='modal' data-target='#modalEliminarDirectivo' title="Eliminar Registro"><i class="far fa-trash-alt"></i></button>`
}
],
"fnFooterCallback": function(nRow, aaData, iStart, iEnd, aiDisplay) {
if (aiDisplay.length > 0) {
$('body').removeClass('no-record');
} else {
$('body').addClass('no-record');
}
},
responsive: true,
autoWidth: false,
language: idiomaDataTable,
lengthChange: true,
buttons: ['copy', 'excel', 'csv', 'pdf', 'colvis'],
dom: 'Bfltip'
});
obtenerdatosDT(tableDirectivo);
}