Added ellipses to truncated media label if the media label is larger than the truncation size. (#471)

This commit is contained in:
Jas Singh
2024-11-09 17:18:29 -08:00
committed by GitHub
parent 7bad1639cf
commit fabec34557

View File

@@ -73,8 +73,13 @@ export const generateMediaLabel = (
},
);
const mediaLabel =
truncation_size.value > 0 ? truncatedLabel.substring(0, truncation_size.value) : truncatedLabel;
const maxLabelSize = truncation_size.value;
let mediaLabel = truncatedLabel;
if (maxLabelSize > 0 && truncatedLabel.length > maxLabelSize) {
mediaLabel = `${truncatedLabel.substring(0, maxLabelSize)}...`;
}
return mediaLabel.length ? mediaLabel : 'Media';
} else {