Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@field with Images can't declare size #24

Closed
kupoback opened this issue Oct 16, 2019 · 8 comments
Closed

@field with Images can't declare size #24

kupoback opened this issue Oct 16, 2019 · 8 comments
Labels
enhancement New feature or request todo This feature or request is on the todo list.

Comments

@kupoback
Copy link

When using the @field with an array image, as the third parameter is the ID, I didn't see anywhere in the documentation on how to declare sizes and image_size within the directive. Was there something I'm missing, or something not understood?

@Log1x
Copy link
Owner

Log1x commented Oct 16, 2019

How about @image?

@kupoback
Copy link
Author

Didn't see that in the docs at all, i'll dig through the code and see what the params are

@kupoback
Copy link
Author

kupoback commented Oct 16, 2019

Ah, it's part of the WP portion of it. You have to hardcode the alt tag tho?

EDIT2: This works, but not exactly ideal as the @image still hardcodes in the width and height. Thanks

@Log1x
Copy link
Owner

Log1x commented Oct 16, 2019

Does it still hardcode width/height with full passed as the second param?

https://developer.wordpress.org/reference/functions/wp_get_attachment_image/

The directive is more or less the above with some magic for getting the image ID (e.g. ACF fields, etc.) and no $icon param.

@kupoback
Copy link
Author

@Log1x Yes it does @image('field_name', 'full') returns the following, I cut out the url's.
<img width="2200" height="1387" src="{url}" class="attachment-full size-full" alt="" srcset="{srcset_urls}" sizes="(max-width: 2200px) 100vw, 2200px">

@Log1x
Copy link
Owner

Log1x commented Oct 16, 2019

Gotcha.

width and height aren't actually being set, but being set by the browser from the srcset/sizes which seemingly can't be unset due to https://core.trac.wordpress.org/browser/tags/5.2/src/wp-includes/media.php#L891

It looks like the best option might be to do something where if the second param is something like raw, it will use a different method for returning the image.

@Log1x Log1x reopened this Oct 16, 2019
@kupoback
Copy link
Author

Would it be a duplication or a pain to create a @fieldimage('field', ['param'], 'id') incase someone actually gets full use out of the @image() directive?

@Log1x Log1x added enhancement New feature or request todo This feature or request is on the todo list. labels Dec 2, 2019
Log1x added a commit that referenced this issue Dec 2, 2019
… an attachment URL (Fixes #24)

bugfix(set): allow the second parameter to accept a value containing commas (e.g. an array) (Fixes #28)
enhancement(utilities): add `limit` param to the `parse` method to allow passing a limit to `explode()` (#28)
docs(update): add `@image` example for `raw`
@Log1x
Copy link
Owner

Log1x commented Dec 2, 2019

I'm publishing a release now that allows you to pass raw as a second parameter to return a URL instead of an <img>. That seems like the best case-scenario with this ticket being set as wont fix.

@Log1x Log1x closed this as completed Dec 2, 2019
Log1x added a commit that referenced this issue Dec 2, 2019
* feature(image): allow passing `raw` as the second parameter to return an attachment URL (Fixes #24)
* bugfix(set): allow the second parameter to accept a value containing commas (e.g. an array) (Fixes #28)
* enhancement(utilities): add `limit` param to the `parse` method to allow passing a limit to `explode()` (#28)
docs(update): add `@image` example for `raw`
* chore(deps): Bump lock files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request todo This feature or request is on the todo list.
Projects
None yet
Development

No branches or pull requests

2 participants