Ghost/ghost/admin/app/components/custom-theme-settings/image.js
Kevin Ansfield 53bdb5720f Added support for image custom theme settings
refs https://github.com/TryGhost/Team/issues/1109

- added `<CustomThemeSettings::Image>`  component that is displayed for any custom theme settings with the type `'image'`
2021-10-14 18:43:04 +01:00

30 lines
771 B
JavaScript

import Component from '@glimmer/component';
import {
IMAGE_EXTENSIONS,
IMAGE_MIME_TYPES
} from 'ghost-admin/components/gh-image-uploader';
import {action} from '@ember/object';
import {camelize} from '@ember/string';
import {guidFor} from '@ember/object/internals';
export default class CustomThemeSettingsImageComponent extends Component {
inputId = `input-${guidFor(this)}`;
inputName = camelize(this.args.setting.key);
imageExtensions = IMAGE_EXTENSIONS;
imageMimeTypes = IMAGE_MIME_TYPES;
@action
imageUploaded(images) {
if (images[0]) {
this.updateValue(images[0].url);
}
}
@action
updateValue(value) {
this.args.setting.set('value', value);
this.args.onChange?.();
}
}