strip data image base64 prefix before storing foto, show dummy profile img when foto is null in DetailsHeader

This commit is contained in:
Harald Bamberger
2025-09-26 14:33:20 +02:00
parent 464b99b3f9
commit 0df9cf769f
2 changed files with 18 additions and 6 deletions
@@ -276,14 +276,19 @@ class Student extends FHCAPI_Controller
$update_person = array();
foreach ($array_allowed_props_person as $prop) {
$val = $this->input->post($prop);
if ($val !== null)
if ($val === null)
{
continue;
}
if($prop == 'foto')
{
$fotoval = ($val == '') ? null : str_replace('data:image/jpeg;base64,', '', $val);
$update_person[$prop] = $fotoval;
}
else
{
$update_person[$prop] = $val;
}
if($prop == 'foto' && $val == '')
{
$update_person[$prop] = null;
}
}
$array_allowed_props_student = ['matrikelnr'];
@@ -102,6 +102,13 @@ export default {
redirectToLeitung(){
this.$emit('redirectToLeitung', {
person_id: this.leitungData.person_id});
},
getFotoSrc(foto) {
if(foto === null) {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + 'skin/images/profilbild_dummy.jpg';
} else {
return 'data:image/jpeg;base64,' + foto;
}
}
},
template: `
@@ -116,7 +123,7 @@ export default {
<img
class="d-block h-100 rounded"
alt="Profilbild"
:src="'data:image/jpeg;base64,' + person.foto"
:src="getFotoSrc(person.foto)"
/>
<template v-if="person.foto_sperre">