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

Possible to get image upload dimensions? #62

Closed
MickeyKay opened this issue Mar 18, 2014 · 11 comments
Closed

Possible to get image upload dimensions? #62

MickeyKay opened this issue Mar 18, 2014 · 11 comments

Comments

@MickeyKay
Copy link
Contributor

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!

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

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 __toString() that would still give out the direct image URL.

Thoughts?

@philipnewcomer
Copy link

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/

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

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.

@philipnewcomer
Copy link

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.

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

We can make the upload field look like #45

@philipnewcomer
Copy link

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.

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

How about setting both #45 and the image option to just accept locally
uploaded images (the WordPress way :). Then we can also remove the url
field.

@philipnewcomer
Copy link

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.

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

Yea, we'll need to add an icon or something in there :)

@bfintal
Copy link
Contributor

bfintal commented Mar 18, 2014

Moved to #66

@bfintal bfintal closed this as completed Mar 18, 2014
@MickeyKay
Copy link
Contributor Author

Awesome. I like where this is going!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants