GithubHelp home page GithubHelp logo

Comments (2)

bertwillekens avatar bertwillekens commented on June 27, 2024

Having the same issue with using it in Kirby Builder.

The issue is caused by an exception that occurs in the 'ratio' prop function:

'ratio' => function($ratio = '1/1') {
$computed = 1;
if (preg_match('/(\d+)(?:\s*)([\/])(?:\s*)(\d+)/', $ratio, $matches) !== false){
$computed = $matches[3] / $matches[1];
}
$computed = $computed * 100;
$ratio = round($computed, 3, PHP_ROUND_HALF_DOWN);
return $ratio;
},

The 'ratio' function is being called multiple times. The first time, it gets the proper ratio value as a parameter. Subsequent times, it is called with its latest return value as the parameter. I.e. first it gets called with "1/2", then it gets called again with 200, causing an exception on line 28.

It seems like the calling code (I suppose Kirby Builder) is messing up by calling the prop function again with its own return value.

This a temporary fix I applied locally:

function ($ratio = '1/1') {
            if (is_numeric($ratio)) {
                return $ratio;
            }
// ...
}

When the function gets called again with its computed numeric value, I'm returning that value.

from kirby-imageradio.

sylvainjule avatar sylvainjule commented on June 27, 2024

Hello,

Thanks for the kind words!

I don't have any issue with the when: attribute with 3.2, have you given it a shot? I'll close this for more clarity in my tickets, feel free to reopen if the problem is still here.

As for the Builder issue, the field should behave properly even when hidden. It seems that the issue is on the Builder's side, you should rather open an issue there. Thank you for the investigation @bertwillekens, and the workaround. I won't add it in the field since there shouldn't be a need for it at all, but it can be of use if Tim doesn't have time to look into it in the near future.

from kirby-imageradio.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.