-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to embed local file images to a blog post model #1545
Comments
There isn't a great option, but there is a basic one. No upload, simply linking an existing image that is on the web somewhere. The basic option is adding the TinyMCE In your keystone.js: keystone.init({
...
'wysiwyg additional plugins': 'images',
'wysiwyg additional buttons': 'images',
...
}); (If you already have plugins or buttons, that should be a comma-delimited string, e.g. |
There are several efforts to provide more file upload options. None have been completely folded into Keystone yet. Most require various levels of core integration and need core code shuffled. |
Yeah, i think may be i should wait for those efforts to be merged. Or stick to a "own served image" somehow with the "images" plugin you first mentioned. |
@jeffreypriebe I've thought of writing some plugin for tinymce to serve image ulrs from my own keystonejs server... but... http://www.tinymce.com/wiki.php/Plugin:image It seems it is already there? I mean, i can use the image_list option http://www.tinymce.com/wiki.php/Configuration:image_list, under Example of JSON url with images |
That image-list is interesting. I don't see anything in the source that would suggest that it would work but the idea of passing it a script/url that provides images to pick from is enticing. |
No demo. Just you have to configure keysonejs like this: keystone.init({
...
'wysiwyg additional plugins': 'image',
'wysiwyg additional buttons': 'image',
'wysiwyg additional options': {
'image_list' : '/images',
}
...
}); And then implement the // Bind Routes
exports = module.exports = function(app) {
....
app.get('/images', function(req, res, next) {
// Just an example. Ideally an array would be fetched from disk, database, etc
res.json([
{title: 'Dog', value: 'mydog.jpg'},
{title: 'Cat', value: 'mycat.gif'}
]);
});
....
} |
Anyway, i've come to a simple implementation, by using available things like data uri for images https://en.wikipedia.org/wiki/Data_URI_scheme and TinyMCE support for drag/drop or paste images. So i dont need to save the images on its own files; also, a blog post is somehow like a unit (text + embeded images), somebody can point me disavantages/cons of this model, but i prefer looking at advantages/pros; and also it's VERY easy to forget the problem, and start USING it! I've simply done this: Enable pasted images as data-uris on TinyMCE (disabled by default)keystone.init({
...
'wysiwyg additional plugins': 'paste',
'wysiwyg additional options': {
'paste_data_images': true
}
...
}); |
So the image selected gets inserted in the content directly as the data/base64. From the last keystone init code, seems like that behavior is a TinyMCE option. I can't think of any good arguments against the insertion of image data directly. On the plus side, it has a strong performance point of saving another HTTP request (Yahoo! goes as far as recommending inline images with data:URL use for exactly this reason.) Feels like a clever judo solution. Nicely done. |
Nice... Yahoo supporting... me! ;) |
Hi @jacargentina |
@tobeatiger never. Maybe i've not used anything so big yet. |
I've searched for an example, but every of those just have 1 image using CloudinaryImage
What i wanted is to have a Blog model with its Html field, but attach some "Local" images to it, and be able to embed those on the html body
Any advice is welcome!
The text was updated successfully, but these errors were encountered: