Chris Falkenstein Posted August 30, 2017 Share Posted August 30, 2017 Hi all, I created a Hanna Code that allows a client to embed a image. First they upload an image to the page (using the images field). Then they use Hanna Code to embed it. The Hanna Code looks like the following. [[image file='myimage.jpg' caption="my image" align='center']] I'd like to set a max-width on the generated HTML img tag. I need the width of the image. How can I get it? So I need a way to get the image width based on the name of the image? Any ideas? Link to comment Share on other sites More sharing options...
louisstephens Posted August 30, 2017 Share Posted August 30, 2017 Under the "Input" tab for the field (in question), you can set the max width and/or max height for uploaded images. However, if you are trying to output a max-width property for use with your hanna code, My "solution" might not be what you are looking for. Link to comment Share on other sites More sharing options...
Chris Falkenstein Posted August 30, 2017 Author Share Posted August 30, 2017 Thanks for the response. I need the width so I can set the max-width css property of the img tag. I need the value of the width. Is there a Processwire method/function for that which I can use when coding my Hanna Code? Link to comment Share on other sites More sharing options...
adrian Posted August 30, 2017 Share Posted August 30, 2017 $image = $page->images->get("name=myimage.jpg"); $image->width(); 2 Link to comment Share on other sites More sharing options...
Chris Falkenstein Posted August 30, 2017 Author Share Posted August 30, 2017 Boom. Perfect. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now