简体   繁体   中英

Trying to display image in guillotine.js with dynamic width & height. Working fine with fixed width & height

Trying to display image in guillotine.js with dynamic width & height. Working fine with fixed width & height.

jQuery(function() {

      var picture = $('#sample_picture');

      // Make sure the image is completely loaded before calling the plugin
      picture.one('load', function(){
        // Initialize plugin (with custom event)
        picture.guillotine({

         var mysize = '<?php echo $size1 ; ?>';
         switch(mysize) {

         case '9x11':
          width: 268, 
          height: 375,
          break;
          }
          eventOnChange: 'guillotinechange'});

Its working fine with fixed width & height

picture.guillotine({

          width: 314, 
          height: 224,
          }
          eventOnChange: 'guillotinechange'});

Note: Variable $size1 from php assigned to mysize correctly.

Help me sort out this issue. Thanks

the main

Your method to work not is so good, you could know about of identation and later is understand how work the programing lenguage. Later that saw your develop problem i try to solve your code issue and i could solved it seeing you fixed example(has errors) and i did it. i hope help you

jQuery(function() {
let picture = $('#sample_picture');

// Make sure the image is completely loaded before calling the plugin
picture.one('load', ()=>{
    // Initialize plugin (with custom event)


    let mysize = '<?php echo $size1 ; ?>',
        sizes={}
    switch(mysize) {

        case '9x11':
            sizes={
                width: 268, 
                height: 375,
            }
        break;
    }
    picture.guillotine(sizes
    eventOnChange: 'guillotinechange'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM