Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tangible

    (@tangibleinc)

    Hi @douglasmikado, there is indeed! This would depend on whether the image you’re working with is the post’s featured image or some other image custom field. If you’re working with the featured image, you can use the regular HTML img tag and its attributes to set the size of the image.

    So in practice, this tag simply displays a post’s featured image:

    
    <Field image />
    

    In contrast, using something like this instead with the img tag would give you a lot more control over how it gets displayed, such as the render size. Note that you can dynamically fill whatever values you need using the Field tag with the image_* attribute (noted here) where that asterisk is a wildcard for any field from the attachment loop.

    
    <img src="{Field image_url}" alt="{Field image_alt}" width="500">
    

    If you’re working with a custom image field, the approach is quite similar and you’d still want to use the img tag but you’ll need to wrap it in an attachment loop. Check out this how-to guide for an explanation if you’re working with a custom img field.

    • This reply was modified 2 years, 2 months ago by Tangible. Reason: Added an example if you're not working with a post's featured image
    Thread Starter douglasmikado

    (@douglasmikado)

    What I try to do is to use the resized (medium) image by wordpress, not the original image resized in the browser.
    For now I can only display the original image in the loop but the size is too big for an overview page. Could you give an example how to achieve this?

    Hi @douglasmikado, you might want to take a look at the documentation for the attachment loop if you haven’t already. It lists all the fields that you can display in an attachment loop which are all the same fields you can display by appending things to that image_* attribute I mentioned in my previous post. If you scroll to the bottom you’ll see that the url field “Accepts optional attribute “size” for image size” so in practice that would look something like <img src="{Field image_url size=thumbnail}" /> if you wanted to use the thumbnail image size. You could also use any of the other default WordPress image sizes. Hope that helps!

    • This reply was modified 2 years, 2 months ago by Ben @ Team Tangible. Reason: fixed code formatting
    Thread Starter douglasmikado

    (@douglasmikado)

    Yes this helps! Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can I choose the render size of an image field?’ is closed to new replies.