You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Desktop: Improved custom icon selection
This commit is contained in:
@@ -17,6 +17,7 @@ const toRelative = require('relative');
|
||||
const timers = require('timers');
|
||||
const zlib = require('zlib');
|
||||
const dgram = require('dgram');
|
||||
const { basename, fileExtension, safeFileExtension } = require('./path-utils');
|
||||
|
||||
function fileExists(filePath) {
|
||||
try {
|
||||
@@ -230,7 +231,6 @@ function shimInit(options = null) {
|
||||
const imageType = require('image-type');
|
||||
|
||||
const uuid = require('./uuid').default;
|
||||
const { basename, fileExtension, safeFileExtension } = require('./path-utils');
|
||||
|
||||
if (!(await fs.pathExists(filePath))) throw new Error(_('Cannot access %s', filePath));
|
||||
|
||||
@@ -336,6 +336,9 @@ function shimInit(options = null) {
|
||||
const image = nativeImage.createFromPath(filePath);
|
||||
if (!image) throw new Error(`Could not load image: ${filePath}`);
|
||||
|
||||
const ext = fileExtension(filePath).toLowerCase();
|
||||
if (!['jpg', 'jpeg', 'png'].includes(ext)) throw new Error(`Unsupported file format: ${ext}`);
|
||||
|
||||
if (maxSize) {
|
||||
const size = image.getSize();
|
||||
if (size.width > maxSize || size.height > maxSize) throw new Error(`Image cannot be larger than ${maxSize}x${maxSize} pixels`);
|
||||
|
||||
Reference in New Issue
Block a user