Giter Site home page Giter Site logo

Comments (8)

Log1x avatar Log1x commented on May 20, 2024 1

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.

from sage-directives.

Log1x avatar Log1x commented on May 20, 2024

How about @image?

from sage-directives.

kupoback avatar kupoback commented on May 20, 2024

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

from sage-directives.

kupoback avatar kupoback commented on May 20, 2024

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

from sage-directives.

Log1x avatar Log1x commented on May 20, 2024

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.

from sage-directives.

kupoback avatar kupoback commented on May 20, 2024

@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">

from sage-directives.

kupoback avatar kupoback commented on May 20, 2024

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?

from sage-directives.

Log1x avatar Log1x commented on May 20, 2024

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.

from sage-directives.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.