diff --git a/ghost/admin/app/components/gh-image-uploader.js b/ghost/admin/app/components/gh-image-uploader.js index 3be2ccbb1d..3311785082 100644 --- a/ghost/admin/app/components/gh-image-uploader.js +++ b/ghost/admin/app/components/gh-image-uploader.js @@ -20,6 +20,7 @@ export default Component.extend({ image: null, text: '', + altText: '', saveButton: true, dragClass: null, @@ -44,6 +45,12 @@ export default Component.extend({ return formData; }), + description: computed('text', 'altText', function () { + let altText = this.get('altText'); + + return this.get('text') || (altText ? `Upload image of "${altText}"` : 'Upload an image'); + }), + progressStyle: computed('uploadPercentage', function () { let percentage = this.get('uploadPercentage'); let width = ''; diff --git a/ghost/admin/app/templates/components/gh-ed-preview.hbs b/ghost/admin/app/templates/components/gh-ed-preview.hbs index a76c2ffc59..6b7dc86f93 100644 --- a/ghost/admin/app/templates/components/gh-ed-preview.hbs +++ b/ghost/admin/app/templates/components/gh-ed-preview.hbs @@ -4,7 +4,7 @@ {{#ember-wormhole to=uploader.destinationElementId}} {{gh-image-uploader-with-preview image=uploader.src - text=uploader.altText + altText=uploader.altText update=(action "updateImageSrc" uploader.index) remove=(action "updateImageSrc" uploader.index "") uploadStarted=uploadStarted diff --git a/ghost/admin/app/templates/components/gh-image-uploader-with-preview.hbs b/ghost/admin/app/templates/components/gh-image-uploader-with-preview.hbs index 9481d4c482..820a81a69c 100644 --- a/ghost/admin/app/templates/components/gh-image-uploader-with-preview.hbs +++ b/ghost/admin/app/templates/components/gh-image-uploader-with-preview.hbs @@ -8,9 +8,11 @@ {{else}} {{gh-image-uploader text=text + altText=altText update=(action 'update') onInput=(action 'onInput') uploadStarted=(action 'uploadStarted') uploadFinished=(action 'uploadFinished') - formChanged=(action 'formChanged')}} + formChanged=(action 'formChanged') + }} {{/if}} diff --git a/ghost/admin/app/templates/components/gh-image-uploader.hbs b/ghost/admin/app/templates/components/gh-image-uploader.hbs index cbfef5fcf5..8bf94b778e 100644 --- a/ghost/admin/app/templates/components/gh-image-uploader.hbs +++ b/ghost/admin/app/templates/components/gh-image-uploader.hbs @@ -15,8 +15,8 @@ {{#if showUploadForm}} {{!-- file selection/drag-n-drop --}}
- {{#gh-file-input multiple=false alt=text action=(action 'fileSelected') accept="image/gif,image/jpg,image/jpeg,image/png,image/svg+xml"}} -
{{if text (concat "Upload image of " text) "Upload an image"}}
+ {{#gh-file-input multiple=false alt=description action=(action 'fileSelected') accept="image/gif,image/jpg,image/jpeg,image/png,image/svg+xml"}} +
{{description}}
{{/gh-file-input}}
@@ -30,7 +30,7 @@ {{#if saveButton}} {{else}} -
{{if text (concat "Upload image of " text) "Upload an image"}}
+
{{description}}
{{/if}} diff --git a/ghost/admin/app/templates/post-settings-menu.hbs b/ghost/admin/app/templates/post-settings-menu.hbs index 210adfa3cd..1a8f2f3b7b 100644 --- a/ghost/admin/app/templates/post-settings-menu.hbs +++ b/ghost/admin/app/templates/post-settings-menu.hbs @@ -10,7 +10,8 @@ image=model.image text="Add post image" update=(action "setCoverImage") - remove=(action "clearCoverImage")}} + remove=(action "clearCoverImage") + }}
diff --git a/ghost/admin/tests/integration/components/gh-image-uploader-test.js b/ghost/admin/tests/integration/components/gh-image-uploader-test.js index 123e8722c0..01d6cc913c 100644 --- a/ghost/admin/tests/integration/components/gh-image-uploader-test.js +++ b/ghost/admin/tests/integration/components/gh-image-uploader-test.js @@ -130,9 +130,14 @@ describeComponent( }); describe('file upload form', function () { + it('renders form with supplied alt text', function () { + this.render(hbs`{{gh-image-uploader image=image altText="text test"}}`); + expect(this.$('.description').text().trim()).to.equal('Upload image of "text test"'); + }); + it('renders form with supplied text', function () { this.render(hbs`{{gh-image-uploader image=image text="text test"}}`); - expect(this.$('.description').text().trim()).to.equal('Upload image of text test'); + expect(this.$('.description').text().trim()).to.equal('text test'); }); it('generates request to correct endpoint', function (done) { @@ -433,7 +438,7 @@ describeComponent( it('can render without a save button', function () { this.render(hbs`{{gh-image-uploader image=image saveButton=false text="text test"}}`); expect(this.$('button').length).to.equal(0); - expect(this.$('.description').text().trim()).to.equal('Upload image of text test'); + expect(this.$('.description').text().trim()).to.equal('text test'); }); it('fires update action when save button clicked', function () {