opengovernment / askthem

Monitor and interact with local governments in the United States
GNU Affero General Public License v3.0
41 stars 15 forks source link

Questions list not showing avatars in when it should. #13

Closed walter closed 11 years ago

walter commented 11 years ago

May be specific to federal legislator avatars.

Transferred from an ops issue..

derekeder commented 11 years ago

A few things going on here, it looks like:

First http://d2xfsikitl0nz3.cloudfront.net/ being appended to an already fully pathed URL (https://github.com/opengovernment/opengovernment-app/blob/master/app/helpers/application_helper.rb#L110).

example: http://d2xfsikitl0nz3.cloudfront.net/http%3A%2F%2Fballotpedia.org%2Fwiki%2Fimages%2FVitoLopez.jpg/20/20

Second, once you fix the URL for Vito Lopez, the image path is still not quite right.

walter commented 11 years ago

Here's an example format for using cloudfront successfully for an avatar (from /vt/people):

http://d2xfsikitl0nz3.cloudfront.net/http%3A%2F%2Fvermont-elections.org%2F2009-2010BioBook%2Fjpegs%2Fancel.jpg/60/60

Cloudfront is a CDN and caches the image file at the URL passed to it via the encoded URL in the path at the dimensions following the encoded URL with directories for the dimensions, i.e. the /60/60/.

So what you mentioned, to my mind, should be working when requested from Cloudfront.

The question is why is this pattern not working like the /60/60/ dimensions?

derekeder commented 11 years ago

Ah yes I see that now. The image is being cached.

So then in the case of: http://oglocal.herokuapp.com/ny/questions, the source image is not found

For Vito Lopez http://d2xfsikitl0nz3.cloudfront.net/http%3A%2F%2Fballotpedia.org%2Fwiki%2Fimages%2FVitoLopez.jpg/20/20 it returns:

Expected content type image/jpeg, image/png, image/gif, image/jpg, got text/html

And the source image yields this page: http://ballotpedia.org/wiki/index.php/Images/VitoLopez.jpg/20/20

My guess is we have an outdated image URL

walter commented 11 years ago

Expected content type image/jpeg, image/png, image/gif, image/jpg, got text/html

Yeah, I have seen that for s3 hosted images that didn't have their content-type set correctly in the past. CDN won't simply rely on extension.

And the source image yields this page: http://ballotpedia.org/wiki/index.php/Images/VitoLopez.jpg/20/20

So in the case of a missing image, ballotpedia.org does indeed return text/html, both for the above (which isn't what CDN would request) and for http://ballotpedia.org/wiki/index.php/Images/VitoLopez.jpg (which CDN would request).

However, we don't rely on a single source for images. In the case of state legislators, each one may have a different URL for the image, including from a different provider domain. I'm not sure that simply having a bad URL for this one particular legislator is the only problem.

When we have a good URL for a person, on this page, does the avatar appear as we expect?

So yes, it looks like the the case of Vito Lopez, our URL does appear to be outdated. What you can do is update his photo_url attribute to via the console and reload the page to check if that fixes the problem or if it persists.

walter commented 11 years ago

I've verified that this IS NOT a problem for officials that don't have their images from ballotpedia.org.

I've opened another issue to deal specifically with the ballotpedia.org based avatars at #28.