1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Improving e-mail design #683

This commit is contained in:
Patrik J. Braun 2023-08-02 23:30:12 +02:00
parent 6f1c42f3d4
commit 6e790677b4

View File

@ -57,6 +57,7 @@ export class EmailMediaMessenger {
' </tbody>\n' + ' </tbody>\n' +
'</table>'; '</table>';
let htmlMiddle = ''; let htmlMiddle = '';
const numberOfColumns = media.length >= 6 ? 3 : 2;
for (let i = 0; i < media.length; ++i) { for (let i = 0; i < media.length; ++i) {
const thPath = await this.getThumbnail(media[i]); const thPath = await this.getThumbnail(media[i]);
const linkUrl = Utils.concatUrls(Config.Server.publicUrl, '/gallery/', encodeURIComponent(path.join(media[i].directory.path, media[i].directory.name))) + const linkUrl = Utils.concatUrls(Config.Server.publicUrl, '/gallery/', encodeURIComponent(path.join(media[i].directory.path, media[i].directory.name))) +
@ -71,15 +72,15 @@ export class EmailMediaMessenger {
path: thPath, path: thPath,
cid: 'img' + i cid: 'img' + i
}); });
if (i % 2 == 0) { if (i % numberOfColumns == 0) {
htmlMiddle += '<tr>'; htmlMiddle += '<tr>';
} }
htmlMiddle += '<td>\n' + htmlMiddle += '<td>\n' +
' <a style="display: block;text-align: center;" href="' + linkUrl + '"><img alt="' + media[i].name + '" style="max-width: 200px; height: 150px" src="cid:img' + i + '"/></a>\n' + ' <a style="display: block;text-align: center;" href="' + linkUrl + '"><img alt="' + media[i].name + '" style="max-width: 200px; max-height: 150px; height:auto; width:auto;" src="cid:img' + i + '"/></a>\n' +
caption + caption +
' </td>\n'; ' </td>\n';
if (i % 2 == 1 || i === media.length - 1) { if (i % numberOfColumns == (numberOfColumns - 1) || i === media.length - 1) {
htmlMiddle += '</tr>'; htmlMiddle += '</tr>';
} }
} }