Ghostdown uses src of url to establish start image for image uploader

closes #401

- adds src of image in editor if url present
- refactored upload plugin as description was being lost
This commit is contained in:
cobbspur 2013-08-18 21:09:23 +01:00
parent 892adf68d7
commit 5dbf1e2d73
2 changed files with 15 additions and 6 deletions

View File

@ -33,6 +33,7 @@
$dropzone.find('a.js-return-image').remove();
$dropzone.find('span.media, div.description, a.image-url, a.image-webcam, div.js-fail, button.js-fail')
.animate({opacity: 0}, 250, function () {
$dropzone.find('div.description').hide().css({"opacity": 100});
if (settings.progressbar) {
$dropzone.find('div.js-fail').after($progress);
$progress.animate({opacity: 100}, 250);
@ -85,6 +86,7 @@
$back.css({"opacity": 100});
$dropzone.find('.js-upload-target').after($back);
}
$dropzone.find('div.description').show();
self.removeExtras();
self.init();
});
@ -133,7 +135,7 @@
},
removeExtras: function () {
$dropzone.find('div.description, span.media, div.js-upload-progress, a.image-url, a.image-webcam, div.js-fail, button.js-fail')
$dropzone.find('span.media, div.js-upload-progress, a.image-url, a.image-webcam, div.js-fail, button.js-fail')
.remove();
},
@ -162,6 +164,7 @@
// This is the start point if an image already exists
source = $dropzone.find('img.js-upload-target').attr('src');
$dropzone.removeClass('image-uploader').addClass('pre-image-uploader');
$dropzone.find('div.description').hide();
if (!$dropzone.find('a.js-edit-image')[0]) {
$link.css({"opacity": 100});
@ -173,6 +176,7 @@
$dropzone.find('img.js-upload-target').attr({"src": ""}).css({"display": "none"});
$back.css({"cursor": "pointer", "z-index": 9999, "opacity": 100});
$dropzone.find('.js-upload-target').after($back);
$dropzone.find('div.description').show();
self.init();
});
},

View File

@ -5,11 +5,16 @@
{
type: 'lang',
filter: function (source) {
return source.replace(/\n?!(?:image)?\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, a) {
return '<section class="js-drop-zone image-uploader">' +
'<div class="description">Add image of <strong>' + alt + '</strong></div>' +
'<input data-url="upload" class="js-fileupload fileupload" type="file" name="uploadimage">' +
'</section>';
return source.replace(/\n?!(?:image)?\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, src) {
var result = "";
if (src !== "http://") {
result = '<img class="js-upload-target" src="' + src + '"/>';
}
return '<section class="js-drop-zone image-uploader">' + result +
'<div class="description">Add image of <strong>' + alt + '</strong></div>' +
'<input data-url="upload" class="js-fileupload fileupload" type="file" name="uploadimage">' +
'</section>';
});
}
}