Crop Image or Display Custom Image Size

WordPress Resolved
24 July, 2019 05:53:02
underdog
Topics: 5
Messages: 15
I want to display the image set in a custom field at a specific size (such as set by the add_image_size() function in the theme). At the moment the plugin only appears to output the url of the full size image when using [meta key="x"]. The problem is that the image ends up being distorted as the image dimension don't fit the container I've set on my template.
24 July, 2019 07:46:52
E2Pdf
Support
Topics: 7
Messages: 3176
Hi,

If it's post thumbnail you can define size with "size" attribute on post thumbnail shortcode: [post_thumbnail size="full"], but in any case it's need to check "Keep Dimension" option to have image save its proportions. You can set it via "Right Mouse Click" -> "Properties" -> "Keep Dimension". (screenshot attached). Image will be fitted depending on options set.

We remain at your service.


We would really appreciate your feedback at WordPress.org!
24 July, 2019 08:28:34
underdog
Topics: 5
Messages: 15
Thank you but that's not quite what I need. This is not the post thumbnail, it is an image served from a custom field and I want the image to either fill the container on the template or output a cropped version of the image in a particular size. The 'Keep Dimension' option isn't helpful to me unfortunately as I always want the image to fill the space assigned in the template.
24 July, 2019 09:13:44
E2Pdf
Support
Topics: 7
Messages: 3176
Unfortunately it's not possible at this moment. We will check the possibility to extend "Image" functionality and [meta] keys usage in that way.

As a possible solution you can try to create another custom field which will contain path to already resized image url but it seems would require coding or some other 3rd party plugins to make to automate the process with existing posts.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
24 July, 2019 09:21:38
underdog
Topics: 5
Messages: 15
Thank you. Another way I thought of doing it was trying to return the attachment url using [meta key="mymeta" attachment_url="true"] where the custom field value is the ID or [meta key="mymeta"] where the return value is the url. I wanted to then use this in an inline style on the container, so 'style="background-size:cover; background-image:url('[meta key="mymeta" attachment_url="true"]";' . This doesn't work - I suspect because of the use of double quotes, but I can't seem to escape the characters either. Do you see where I'm going with this?
24 July, 2019 10:07:41
E2Pdf
Support
Topics: 7
Messages: 3176
"background-size" and "background-image" is not yet supported by our engine so it will not work even if quotes will be corrected. The only way at this moment is to prepare image before sending to PDF.

Do you have attachment IDs inside meta post field as value? Or URLs?

We remain at your service.
We would really appreciate your feedback at WordPress.org!
24 July, 2019 10:51:15
E2Pdf
Support
Topics: 7
Messages: 3176
We just released an update (1.08.06) with "attachment_image_url" support for meta keys. It will work if you have IDs inside meta key values. With this attribute you can also define registered size.

Usage: [meta key="mymeta" attachment_image_url="true" size="full"]

We remain at your service.
We would really appreciate your feedback at WordPress.org!
25 July, 2019 01:08:21
underdog
Topics: 5
Messages: 15
Wow! I mean there's customer support and there's customer support but this is really going above and beyond. Thank you so much, this is so helpful and will help me achieve exactly what I need. Amazing.