I would like create a sprite with Gulp, create a CSS file with coordinates automatically and insert the image from this sprite with name, like :
.my_class {
background-image: url("images/my-image.png");
}
After a research I would like use gulp-sprite-generator but I do not understand how I can use it.
In my gulp file I add the configuration of this plugin :
gulp.task('sprites', function () {
var spriteOutput = gulp.src(app + '/css/*.css')
.pipe(plugins.spriteGenerator({
baseUrl: 'app/images/sprite',
spriteSheetName: 'sprite.png',
spriteSheetPath: 'dist/images/'
})
);
spriteOutput.css.pipe(gulp.dest('dist/css/'));
spriteOutput.img.pipe(gulp.dest('dist/images/'));
});
But when I call gulp sprites in a Terminal, no sprites are created.
So, I guess I need use the CSS for tell him to create some sprite from the sprite folder but I don't get it.
Thanks for your help.
I have done some work around and found gulp.spritesmith plugin
https://github.com/twolfson/gulp.spritesmith
using this plugins I am able to create sprites image and css for my application.
that's how I did it...
var spritesmith = require('gulp.spritesmith');
// Sprites task - create sprite image
gulp.task('sprites', function () {
var spriteData = gulp.src(paths.source.images).pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css',
imgPath: paths.build.images + 'sprite.png'
}));
spriteData.css.pipe(gulp.dest(paths.build.css));
spriteData.img.pipe(gulp.dest(paths.build.images));
});
this way you'll get sprite.css file in destination css folder and sprite.png in destination images folder.
Look at the example – https://github.com/alex-chuev/gulp-sprite-example. It is usable.
But I also met a problem. I had saved my images from Photoshop with Ctrl + Alt + Shift + S and I got the same message:
Created 0 sprite(s) from 0 images, saved 0% requests
I have resolved the issue by disabling the "Interlaced" checkbox in the save dialog:
Related
I've got this script:
function testchartbuild() {
var sheet = SpreadsheetApp.getActiveSheet();
var chart = sheet.newChart()
.setChartType(Charts.ChartType.LINE)
.asLineChart()
.setOption("useFirstColumnAsDomain", false)
.addRange(sheet.getRange("BA24:BD231"))
.setNumHeaders(1)
.setPosition(5, 5, 0, 0)
.setOption("legend", {position: "bottom"})
.setOption("width", 690)
.setOption("height", 195)
.build();
// create an image from that EmbeddedChart
sheet.insertImage(chart.getBlob(),58,2); // this works
};
It currently works great to create a chart, and display it as an image on my sheet. I am doing it this way because I can't create a chart above a locked row. Each time I run the script, it creates a new image on top of the old image (if the script was run previously). I would like to edit the script so that it looks to see if another image is already there first, deletes it, then replaces it with the new chart image. I've been looking everywhere to find a way to delete the old image first but can't figure it out. Any help would be great! Thanks
In your situation, in order to remove the existing image with the anchor cell "BF2", how about the following modification?
From:
.build();
// create an image from that EmbeddedChart
sheet.insertImage(chart.getBlob(),58,2); // this works
To:
.build();
sheet.getImages().forEach(e => {
if (e.getAnchorCell().getA1Notation() == "BF2") {
e.remove();
}
});
// create an image from that EmbeddedChart
sheet.insertImage(chart.getBlob(),58,2); // this works
Note:
If you want to remove all existing images, please modify the above modification as follows.
sheet.getImages().forEach(e => e.remove());
References:
getImages()
remove()
I've managed to upload images through drag & drop to a SP 2013 library by intercepting the paste and fileUploadrequest events (+ added mandatory headers and used /_api/web/getfolderbyserverrelativeurl(\'/sites/theSite/theLibrary\')/files/add(overwrite=true,%20url=\'aDynamicFilename.jpg\') as the request's URL).
The problem with this approach is that even if the image is uploaded, the image is not inserted in the editor (no error). I'm not setting config.uploadUrl for this approach.
Q#1: Is there any step which I should go through after the image is uploaded? Like telling the CKEDITOR instance to insert the image?
Later on, I've noticed that if I'm setting the config.uploadUrl to the same URL as I'm using above, the editor inserts successfully the image. The problem is that, from my trials, the config.uploadUrl is initialized together with the CKEDITOR instance (therefore, can't be assigned dynamically for each image, in case that multiple images are dragged and dropped on the editor).
Q#2: Is there another way to configure the uploadUrl or maybe some other config property that would allow the custom upload to work and insert the image in the editor?
Eventually made it work by following a similar approach as the on in this repo:
RyanSiu1995/ckeditor-ImageUploader
Use a FileReader and start loading the image when it's pasted to the
CKEditor
On the fileReader's onload event, create a img element in the
editor's document object with some opacity and with the fileReader's
Base64 string as the src
On the fileLoader's uploaded event, remove
the img and re-add it with the actual file's url (changing the src
attribute on the img was not triggering the editor's change event, which I was hooking into,so I chose to replace the whole element)
Here's the relevant section from the ckeditor-ImageUploader plugin:
fileDialog.on('change', function (e) {
var fileTools = CKEDITOR.fileTools,
uploadUrl = fileTools.getUploadUrl( editor.config, 'image' ),
file = e.target.files[0],
loader = editor.uploadRepository.create(file),
reader = new FileReader(),
notification,
img;
// verify
if (!/image/i.test(file.type)) {
notification = editor.showNotification( 'Please check the correct format.', 'warning' );
setTimeout(function() {
notification.hide()
}, 2000);
return false
}
loader.upload(uploadUrl);
// preview image
reader.readAsDataURL(e.target.files[0]);
reader.onload = function (e) {
img = editor.document.createElement('img');
img.setAttribute('src', e.target.result);
img.setStyle('opacity', 0.3);
editor.insertElement(img);
}
loader.on('uploaded', function(evt) {
editor.widgets.initOn(img, 'image', {
src: evt.sender.url
});
img.setAttribute('src', evt.sender.url);
img.setStyle('opacity', 1);
});
loader.on('error', function() {
img.$ && img.$.remove();
});
fileTools.bindNotifications(editor, loader);
// empty input
fileDialog[0].value = "";
I am using CKFinder 3 intergrated with CKEditor. Now, after resizing an Image and clicking on Choose Resized, I want to move/copy the resized image to another folder using javascript. I am able to get upto the following code.
CKFinder.start({
onInit: function (finder) {
finder.on('file:choose:resizedImage', function (event) {
var file = event.data.file;
var resizedData = file.get('imageResizeData');
var resized = file.get('imageResizeData').get('resized');
// Need help here to move the resized image to another folder.
});
}
});
NOTE: I am using ASP.NET Connector.
You can use command:send request to send CopyFiles request:
https://docs-old.ckeditor.com/ckfinder3/#!/api/CKFinder.Application-request-command_send
Parameters taken by CopyFiles can be found here:
https://docs-old.ckeditor.com/ckfinder3-net/commands.html#command_copyfiles
Here is the problem :
I have a canvas, and four (would be more in future, but 4 for testing...anyway, doesn't matter) images that can be "poped" into the canvas by clicking on it.
Each image can be present multiple times in the canvas.
So far, poping is working fine, images are draggable... But I can't add some resize or zIndex function as I can only select the last image add to the canvas.
In a ideal world, I would like, by clicking/dragging an image, put it on top of the canvas, and kinda "select" it, so that I can connect the resize functions to the image.
But with the array of images, I can't manage to identify properly the item dragged, and can't use (or don't manage to use) the selectors.
Thank you.
EDIT : some code
var imgCpt = 0;
var image = [];
function addDetails(img) {
imgCpt++;
var imageObj = new Image();
imageObj.onload = function() {
image[imgCpt] = new Kinetic.Image({
x: 0,
y: 0,
image: imageObj,
draggable: true,
id:image[imgCpt]
});
image[imgCpt].setX((stage.getWidth()/2) - (image[imgCpt].getWidth()/2));
image[imgCpt].setY((stage.getHeight()/2) - (image[imgCpt].getHeight()/2));
eval(image[imgCpt]).on('click', function() {
alert(eval(imgCpt));
});
layer.add(image[imgCpt]);
stage.add(layer);
};
imageObj.src = 'uploads/'+img;
}
I've already tried different solutions : multiple layer, and acting on it instead of acting on image, working with shapes filled with image instead of image, but it's always the same problem : I can't get the id of the concerned element (instead of the id of the last insert element)
This version works with array, but I tried yersterday to build the image id with eval(); without more success.
Thank you for your help
EDIT² : sorry to insist, but I would really be glad to have some assistance on this point, even if I think it's more JS related than pure KineticJS related.
Thank you.
Ok Guys, just solved the problem :
eval("image["+imgCpt+"].on('click', function() {alert("+imgCpt+");});");
Instead of :
eval(image[imgCpt]).on('click', function() {
alert(eval(imgCpt));
});
Now time to set a true action behind the click.
Thank you for helping ;)
Im using this code to change the src attribute of an image tag (using prototype and scriptaculous):
new Effect.Fade("images",{afterFinish:
function()
{
$("detail").setAttribute("src", "img/02.jpg");
new Effect.Appear("images",{duration:0.8});
}
});
Where "images" is the container (a div) and "detail" is the img tag
The result is the current image fades, appears and then the new image suddenly shows.
My question is, how can i check the new image is fully loaded by the browser to trigger the Effect.Appear after?
Is there another way to do this?
Images have an onload event you can hook up to:
$("detail").onload = function()
{ do_stuff(); } // Remember to do this BEFORE changing the src
In my experience, it is a bit flaky sometimes (at times doesn't seem to get executed). It would be better to pre-load the image and allow this effect only after the full document has loaded (onload instead of dom:load or ready).
Replace
new Effect.Appear("images",{duration:0.8});
with
Event.observe("detail", 'load', function() {
new Effect.Appear("images",{duration:0.8});
Event.stopObserving('detail', 'load');
});
To tell the user that you are loading the image, you could set a css background to the image, with a spinnging circle or whatever suits.