profile_pic is an image field, im not using any numerical inputs, just trying to link the images height and width attributes from the code and be able to change it on the front end. Also I looked into the module in design tools but theres no way to set a max or min for the height and width as far as I can see. I think image fields don’t have that feature, but number fields do like you said
I’ll share the code here. Its largely built on the tutorial code, just modified a bit because I was trying to experiment with it to learn some of how this module and hubspot works:
html/hubl:
<div class="testimonial">
<h1 class="testimonial__header">{{module.customer_name}}</h1>
<img src="{{module.profile_pic.src}}" alt="{{module.profile_pic.alt}}" class="testimonial__picture">
{{module.testimonial}}
</div>
//added this bit in here to directly control the image width and height from the front end
{% require_css %}
<style>
.testimonial__picture {
width: {{ module.profile_pic.width ~ "px" }};
height: {{ module.profile_pic.height ~ "px" }};
}
</style>
{% end_require_css %}
the css file
/* this CSS code is modified by me from the original that came from the tutorial, but mostly the same. Just added minor things like margin, border, padding and so on. */
.testimonial {
text-align: center;
width: 300px;
max-width: 25%;
margin: auto;
border: 1px solid black;
padding: 20px;
}
.testimonial__header {
font-weight: bold;
margin: 0;
}
.testimonial__picture {
display: block;
margin: auto;
max-width: 100%;
max-height: 250px;
padding: 10px 0;
}
/* the fields json file */
[ {
"id" : "c9b3f885-5678-0626-6a2c-b622dbc246fe",
"name" : "customer_name",
"display_width" : null,
"label" : "Customer Name",
"required" : false,
"locked" : false,
"validation_regex" : "",
"allow_new_line" : false,
"show_emoji_picker" : false,
"type" : "text",
"default" : "Sally"
}, {
"id" : "7fdf53af-07e2-dd2d-640f-dc13282331a1",
"name" : "profile_pic",
"display_width" : null,
"label" : "Profile Picture",
"required" : false,
"locked" : false,
"responsive" : true,
"resizable" : true,
"show_loading" : false,
"type" : "image",
"default" : {
"size_type" : "auto",
"src" : "https://21802508.fs1.hubspotusercontent-na1.net/hubfs/21802508/profile-pic-sally.svg",
"alt" : "Customer Profile Picture",
"loading" : "lazy",
"width" : 100,
"height" : 100,
"max_width" : 100,
"max_height" : 100
}
}, {
"id" : "fe444827-784a-1be0-460b-a8896532a69a",
"name" : "testimonial",
"display_width" : null,
"label" : "Testimonial",
"required" : false,
"locked" : false,
"type" : "richtext",
"default" : "<span>\"I would 100% recommend it to my colleagues and friends.\"</span>"
} ]