Comments (10)
Well, I have found a workaround: this is to destroy the plugin and to init it again each time the item of my page change.
from croppic.
Hello, I re-open that issue because actually my work around is not that good. The behaviour of the plug-in is much better when it is not destroyed/created each time I display an item on my page through a ajax call.
from croppic.
hi Alplob,
Can you post some sample code , how you you run croppic and where do you think it doesnt refresh i will certainly take a look.
Mat
from croppic.
Hello Sconsult,
Thanks a lot for your reply. My page is made of 2 sections. The left pane includes a list of items and selecting one display it in the the right pane thanks to an ajax call. Below is the code I use. You can see in the function refresh_content that I do not use the method refresh but I modify the option, I destroy and re-initialize Croppic.
// Function called each time an item is displayed in the right pane
function refresh_content(id) {
$.post('./ajax/_item_display.php', { line: id }, function(json) {
$('#item_id').val(json.item_id);
$('#item_code').val(json.item_code);
$('#item_name').val(json.item_name);
....
cropperOptions.imgUrlInit = './files/index.php?type=item&picture_id=' + $('#item_id').val();
cropperOptions.cropData = { 'type_picture': 'item', 'picture_name': $('#item_id').val() };
cropperHeader.destroy();
cropperHeader = new Croppic('item_picture',cropperOptions);
}, 'json');
};
// Initialization
var cropperOptions = {
uploadUrl:'./files/img_save_to_file.php',
cropUrl:'./files/img_crop_to_file.php',
uploadData:{ 'type_picture': 'item' },
cropData:{ 'type_picture': 'item', 'picture_name': $('item_id').val() },
imgUrlInit: './files/index.php?type=item&picture_id=' + $('item_id').val(),
onError: function(errormsg){ console.log('onError:'+errormsg); notification_action_forbidden(errormsg); },
doubleZoomControls:false,
zoomFactor:50,
rotateFactor:90,
rotateControls:true,
modal:true
}
var cropperHeader = new Croppic('item_picture',cropperOptions);
from croppic.
You can do a mask in the button crop and change the object values, like this:
$('.some-button').on('click', function () {
cropperOptions.cropData.picture_name = $('input#sp_id').val();
$('.cropControlCrop').click();
});
from croppic.
Hi @Alplob
Did the solutions from @lucascaprio help you solve the issue ? If yes please close the Issue, otherwise update the issue with your latest response.
Thanks @lucascaprio for being an active part of the open source community
Mat
from croppic.
Not really. Actually I am using Croppic to maintain a facebook of items, which means two actions:
- show the picture of the displayed item (the function refresh_content(id) in my code, with the help of #22 )
- update that picture if the user thinks it is necessary (the normal Croppic usage)
The solution of @lucascaprio works well for the point 2. but not for the point 1. The ideal situation would be that the .reset() method reloads all the options value with their 'instant' value and not keeping those defined when the page got loaded.
from croppic.
Hi @Alplob
Ok let us make a step back. Your original question was that the value, even if changed does not reflect when the same croppic instance is used. The value stays the same.
You are using the following (which is correct)
cropData:{ 'picture_name': $('input#sp_id').val() }
In your refresh function, your reinstatement croppic.
// Function called each time an item is displayed in the right pane
function refresh_content(id) {
$.post('./ajax/_item_display.php', { line: id }, function(json) {
$('#item_id').val(json.item_id);
$('#item_code').val(json.item_code);
$('#item_name').val(json.item_name);
....
cropperOptions.imgUrlInit = './files/index.php?type=item&picture_id=' + $('#item_id').val();
cropperOptions.cropData = { 'type_picture': 'item', 'picture_name': $('#item_id').val() };
cropperHeader.destroy();
cropperHeader = new Croppic('item_picture',cropperOptions);
}, 'json');
};
if i understand you correctly this code is what you want to achieve (replace this in your index for the preload):
var croppicContainerPreloadOptions = {
uploadUrl:'img_save_to_file.php',
cropUrl:'img_crop_to_file.php',
cropData:{ 'type_picture': 'item', 'picture_name': 'test mat'},
loadPicture:'assets/img/night.jpg',
enableMousescroll:true,
onAfterImgCrop:function(){
for (var key in cropContainerPreload.options.cropData) {
if(cropContainerPreload.options.cropData.hasOwnProperty(key) && key == "picture_name") {
alert("before change key: "+key+" value: "+cropContainerPreload.options.cropData[key]);
cropContainerPreload.options.cropData[key] ="new value";
alert("after change key: "+key+" value: "+cropContainerPreload.options.cropData[key]);
}
}
cropContainerPreload.options.cropData },
loaderHtml:'<div class="loader bubblingG"><span id="bubblingG_1"></span><span id="bubblingG_2"></span><span id="bubblingG_3"></span></div> '
}
cropContainerPreload = new Croppic('cropContainerPreload', croppicContainerPreloadOptions);
I utilize there the onAfterImgCrop:function.
When initializing the croppic, the original picture name is "test mat", when the first crop is done, i change the value for the existing croppic instance to "new value". Output example attached.
I believe you could take it from here, to modify the code to your liking without destroying and reinitalizing a new crop.
All without destroying the old and re instantiating a new croppic.
from croppic.
Thanks a lot for your answer, I got your point, that is fine!
from croppic.
You can pass a variable adding:
On the upload image
uploadData:{ 'id': $('#id').val() },
if you want on the crop image
cropData:{ 'id': $('#id').val() },
Insert a input to make the POST variable
and add on the file img_crop_to_file or img_save_to_file
$value= $_POST["id"];
$output_filename = "images/$value";
from croppic.
Related Issues (20)
- Add feature: Drag n Drop
- the site is no more accessible for documentation HOT 1
- Croppic does not generate images HOT 2
- jQuery 3 compatibility issue HOT 3
- Multiple uploading
- Multiple Croppics
- Croppic as App
- Parameter issues ! HOT 1
- Download PHP Example File on your website is not working. HOT 5
- Crop high resolution image and still get a high resolution crop HOT 1
- no works
- Windows 10 Tablet, All Browsers Not Working
- zoom hide
- Can't upload a picture more than 9mo
- Controls missing
- Can`t upload File; no write Access HOT 2
- I need help with trying to save in the original file name.
- Is there or will there be a... No jQuery Version?
- I have 2 question, help please
- Upload Button HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from croppic.