-
Notifications
You must be signed in to change notification settings - Fork 139
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
Possible to get image upload dimensions? #62
Comments
Currently the image upload returns the direct URL to the image. So there is no way to know those. Haven't checked this out yet, but IF WP natively can get the dimensions of an image in the media panel.. would it be better to switch this output to maybe an object containing the media data of the selected image? If we do that, to make it backward compatible, we'll need to create a custom class/object and put in a magic function Thoughts? |
I think it could be really helpful for the image upload field to return the WordPress attachment ID. Then we could use the built-in WordPress functions for getting the image size. Otherwise, we need to resort to ugly hacks like this to get the image attachment ID: http://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/ |
Great idea @philipnewcomer Since Titan doesn't have a ton of usage yet (600 downloads in the plugin page), maybe we can switch it to an ID instead of the URL. |
It gets complicated by the fact that the user could simply paste the URL of an externally-hosted image into the upload field, and in that case there would obviously be no attachment ID. Perhaps the upload field could require that images be chosen from the media library (or uploaded to it), to guarantee that there is always going to be an attachment ID. Or, theme/plugin authors could be made aware that an attachment ID may not always be available, and that they will also need to handle those cases. |
We can make the upload field look like #45 |
Yes, that would be ideal for guaranteeing that an attachment ID is available, but sometimes we may want the user to be able to paste in an external image URL. Perhaps the upload field would behave like in #45 by default, but there would also be an option where we could allow pasting an external URL, in which case we would handle the no-attachment-ID case ourselves. |
How about setting both #45 and the image option to just accept locally |
In that case, we'll also need a "Remove" button, since the user will no longer be able to delete the image URL in order to clear the field. |
Yea, we'll need to add an icon or something in there :) |
Moved to #66 |
Awesome. I like where this is going! |
Hi there,
Is there any native Titan method to get/output the dimensions of an image upload option? I'm thinking this would be really handy for the quick CSS generation method that's available, with sizing a logo area based on the logo's size, for example.
Thanks!
The text was updated successfully, but these errors were encountered: