• Resolved davidslager

    (@davidslager)


    How do I change the width and length of an image based on user input (specifically a slider; fieldname77)?

    I have the following code in the image (HTML) container:

    <div style=”max-width:+[fieldname77]+px;” class=”image-container”></div>

    It obviously isn’t working correctly and I’ve tried several variations of that code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    You can referring to the fields’ values by their names “fieldname#”, only as part of the equations, but not in other contexts. So, you should insert a calculated field in the form, with the “Hide Field From Public Page” checkbox ticked (because this field would be used as auxiliary, and it is not relevant for the form’s interface), and enter as the equation associated to the field, the piece of code below:

    (function(){jQuery('.image-container').css('max-width',fieldname77+'px');})()

    If you need additional help implementing your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter davidslager

    (@davidslager)

    Wow, that works great! If I wanted to add dynamic height to it as well, could I do that in the same function or would I have to create a new function in a new hidden calculated field?

    Plugin Author codepeople

    (@codepeople)

    Hello,

    Modifies all image’s settings in the same equation. For example, assuming that the field for the height is the fieldname123, the equation would be:

    (function(){jQuery('.image-container').css({'max-width':fieldname77+'px', 'height':fieldname123+'px'});})()

    Best regards.

    Thread Starter davidslager

    (@davidslager)

    That works – just one more question related to this:

    How would I change the image size the same way? So instead of changing the image container I want to change the size of the image dynamically in the image container?

    What I’m trying to do is allow the user to stretch the image horizontally and vertically based on their inputs (so the image doesn’t automatically scale but gets distorted). The function you have above doesn’t quite achieve what I am hoping to do.

    Thanks so much – I’m learning with your help!

    Plugin Author codepeople

    (@codepeople)

    Hello,

    You can insert the <img> tag with a class name to identify it with jQuery, and apply the CSS rules to the img tag.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Creating Dynamic Image Sizes based on User Input’ is closed to new replies.