Needs work
Project:
Sunlight Congressional Districts (with optional CiviCRM integration)
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
28 Jan 2013 at 19:51 UTC
Updated:
19 Feb 2013 at 15:06 UTC
Jump to comment: Most recent file
Comments
Comment #1
darrell_ulm commentedHere is the patch to remove broken images from the congress search view, attached.
Comment #2
dalinI don't think I like this approach.
Rather than use JS to hide the image, how about altering cd_sunlight_handler_field_congress_picture->render() so that alt text is not added if the image URL starts with 'http://bioguide.congress.gov/'
P.S. You now have commit access. Can you re-roll the patch, then post here, then I'll get you to commit it to both the D6 and D7 branches.
Comment #3
darrell_ulm commentedAh, didn't notice that the URLs were actually different. Yeah, that'll work. I'll get on it asap.
Comment #4
darrell_ulm commentedThis patch attached here is for 6.x-3.x-dev,
Do you want another one for 7.x-x.x-dev?
I'll need to get it installed in my test Drupal7 instance
Comment #5
dalinWith that patch you actually removed some important functionality that needs to apply even if the images come directly from bioguide (see the inline comments). Instead I think we need to actually set the alt text to '' if the image is coming directly from bioguide.
Nope, once we get it right you can apply to both branches.
Comment #6
darrell_ulm commentedHmmm, however, thinking about this, the link provided, for example:
http://bioguide.congress.gov/bioguide/photo/M/M001153.jpg = good one
http://bioguide.congress.gov/bioguide/photo/R/R000591.jpg = not good one
Could be completely valid, but there is no way to know if the external server cannot get this image.
It possibilities are,
I'm not sure one can make an assumption about the difference between 2. and 3. until an attempt to load the image at the browser render time, and I'm not sure you can do that without a little Javascript.
Thanks!
Comment #7
darrell_ulm commentedOK, new patch attached
I think I see what you mean now, and this is possible w/ the correct options on theme('image' for the specific cases.
Comment #8
dalinLess code duplication == better.
How about something like
Comment #9
darrell_ulm commentedBefore I roll a patch, I had to do modify the getsize param or it didn't work.
Let's go minimal, this one works.
In fact, the $alt param does not seem to affect the image breaking, on Chromimum at least, perhaps it works for other browsers. The getsize parameter seems to be the important one.
Comment #10
darrell_ulm commentedOK, here is a patch of the last comment for D6 dev, attached.
Comment #11
dalinLooking at theme_image, I don't think that's what you want:
http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_image/6
That will result in _no_ image being displayed (since it's from an external domain).
I think we need to back up and figure out what we're trying to accomplish:
1) There needs to be dimensions set somewhere so that the layout doesn't break.
2) We need alt text where possible to maintain accessibility.
3) Don't show image placeholders in webkit browsers (I think that's what you're after).
So if all the above are true then I think we need to:
1) wrap the image in divs to do a manual scale/crop (possibly only if the image is external):
http://www.advomatic.com/blogs/jack-haas/faking-imagecache-external-imag...
but using inline styles rather than a stylesheet
2) Add the JS to remove broken images.
Comment #12
darrell_ulm commentedHmm, a little more complex,
However, also another option it to provide our own placeholder image, a grey box with the name of the congress-person, and or "no image" text, something like that. Then it should always be there so theming can deal with it as they wish.
We could add a class to the missing image class = "cd_sunlight-missing-image"
Would that work to preserve the formatting? Then themer's could always hide or swap out our place-holder missing image.
Just some ideas. Thanks!
Comment #13
dalinBut you don't know if the image is missing or not. The image may be coming directly from bioguide because the admin set that in the field settings, or because the server was unable to connect to the bioguide site to pull the image locally (servers that are unable to connect to the outside world is a common issue).
Comment #14
darrell_ulm commentedAh, that's true. OK, I'll chug away on #11
http://drupal.org/node/1901276#comment-7014042
when I get a chance.
Thank you!
Comment #15
darrell_ulm commentedDalin, patch attached.
Create div around theme('img'.
Jquery to remove broken images, only for the sunlight module views, nothing else, and replaces background w/ greybox, + ALT text when image missing.
Thanks
Comment #16
darrell_ulm commentedUpdated to the correct status for patch at:
http://drupal.org/files/cd_sunlight-d6_replace_remove_missing_images_Jqu...
for update in #15
Comment #17
dalinA few thoughts:
- Rather than using
$(this)multiple times you could do something like this:- We shouldn't be hard-coding colour values. Instead add a class.
- You can also chain some actions:
- Also use hyphens for class/id names rather than underscores.
- This line is the most perplexing, but has no code comments:
What does it do? If it is unnecessary then the .each() loop could be completely removed, leaving just
- Just a note that we'll need to change this for the D7 version to use behaviours:
- We shouldn't switch on view-name, but rather the type of view (node, file, congress) so that if people create other views this code is still applied.
- These sizes seems rather arbitrary. Shouldn't we use the calculated height/width? If not we'll at least need some code comments.
$attributes['style'] = 'height: 250px; width:auto;';return '<div class="cd_sunlight_picture" style=" height:250px; width: 167px;">' . $themed_image . "</div>";Comment #18
darrell_ulm commentedYeah, these things make sense, I slapped it together in a few minutes Friday. I forgot that I even rolled the patch. :D
Glad you're cool on going the Javascript route now, I think given the params, it may be the only reasonable way to handle it.
This is a good point:
I'll get to this again when I have a few minutes.