# Resize images from a shortcode

**URL:** <https://zola.discourse.group/t/resize-images-from-a-shortcode/1583>\
**Category:** Uncategorized\
**Created:** [January 2, 2023, 1:58am UTC](https://zola.discourse.group/t/resize-images-from-a-shortcode/1583 "2023-01-02T01:58:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![theMarina](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/themarina/32/887_2.png) [@theMarina](https://zola.discourse.group/u/theMarina)\
**Post date:** [January 2, 2023, 1:58am UTC](https://zola.discourse.group/t/resize-images-from-a-shortcode/1583/1 "2023-01-02T01:58:46Z")

</div>

Hi, I created shortcodes to resize images and used them for a while. I put asserts in the same directory as the .md file inside the “content” directory, and use this shortcode instead of the markup syntax because I want to format the appearance of the images. I pass a filename of a local asset to the shortcode. Then the shortcode does something similar to:  
\<img src = “{{ receivedurl” }}\>

I noticed that the images are too big, and I want to resize them. I am trying different combinations on this code, but nothing works  
{% set image1 = resize\_image(path=receivedurl, height=250, format=“webp”) %}  
\<img src = “{{ image” }}\>

Can somebody help me, please?

---

<div class="post-metadata">

**Author:** ![magikstm](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/magikstm/32/849_2.png) [@magikstm](https://zola.discourse.group/u/magikstm)\
**Post date:** [January 2, 2023, 6:03am UTC](https://zola.discourse.group/t/resize-images-from-a-shortcode/1583/2 "2023-01-02T06:03:07Z")

</div>

I believe you may be missing a “`width`” parameter or an “`op`” parameter depending on what you wish to accomplish.

You possibly wish to set a “`width`” or use “`op = "fit_height"`”

Ref: [Image processing | Zola](https://www.getzola.org/documentation/content/image-processing/)

---

<div class="post-metadata">

**Author:** ![LunarEclipse](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/lunareclipse/32/1216_2.png) [@LunarEclipse](https://zola.discourse.group/u/LunarEclipse)\
**Post date:** [May 18, 2024, 10:31pm UTC](https://zola.discourse.group/t/resize-images-from-a-shortcode/1583/3 "2024-05-18T22:31:47Z")

</div>

So basically, the problem is that `resize_image` cannot find your image because it’s not getting the full path.

The solution (that doesn’t involve manually writing in the full path into the shortcode) is to do something like this in the shorcode:

```auto
{% set document = page | default(value=section) -%} {# this ensures the shortcode works in both pages and sections -#}
{% set image1 = resize_image(path=document.colocated_path ~ receivedurl, height=250, format="webp") -%}

```

Essentially, `page.colocated_path` or `section.colocated_path` contain the path to where the colocated assets are for the page you’re currently processing, and you need to prepend the `receivedurl` with that path.
