Apr 14

Flickr badge W3C valid

2006 at 07.00 am posted by Veerle Pieters

Some of you might be interested in how the Flickr pictures are implemented on my blog. I use the HTML version of the Flickr badge. After completing the 5 steps you’ll get the code that you’ll need to implement in your site. As we like to keep things clean and W3C valid, we need to do some ‘house cleaning’ first. The styles that Flickr provide are of no use to me so I throw them out and we’ll control everything in our own (external) stylesheet…

In fact, the only thing I need from the code Flickr provides is the script:

  1. <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=3&display=latest&size=s&layout=x&source=user&user=76746199%40N00"></script>

Even this line of code needs a brush up. The ampersands need to be changed into &amp; to make sure it's all valid XHTML code. Next I need to change "count=3"into "count=4" since I want 4 pictures to show up. You can pick any number you want.

The code for the script

This is the code of the script I use:

  1. <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=4&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user&amp;user=76746199%40N00"></script>

The XHTML code

Next step is implementing this script in the XHTML code of my page. This is the code for my flickrness corner:

  1. <div id="flickr">
  2. <h2>Flickrness</h2>
  3. <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=4&amp;..."></script>
  4. </div>

The CSS code

Next is giving this code the proper CSS styles. First I start with the #flickr div container:

  1. #flickr {
  2. background:url(./graphics/flickerness.gif) no-repeat;
  3. width:214px;
  4. height:154 px;
  5. height:168px;
  6. padding:14px 0 0 50px;
  7. padding:0 0 0 50px;
  8. margin-top:40px;
  9. }

The flickrness text is placed as a background image. Then there is the exact height and width and the padding and margin values.

  1. #flickr h2 {
  2. position:absolute;
  3. left:-300px;
  4. top:-300px;
  5. }

The heading 2 text is thrown out of the window by using negative left and top coordinates in combination with absolute positioning. The heading text is there in the code but it won't appear in the layout. This way people who use a text reader or visit the site with the styles switched off, will still be able to read the heading text.

  1. #flickr img {
  2. #flickr a img {
  3. float:left;
  4. margin:0 0px 8px 8px;
  5. background:#3f4e4e;
  6. padding:4px;
  7. width:62px;
  8. height:62px;
  9. }

Onto the styling of the Flickr images. The dimensions of the images are also defined in the CSS. The border around them is achieved by using a padding of 4 pixels and a background color. The space between the images is created by using left and bottom margin of 8 pixels. I use float:left to make them align left.

Update: On Sept. 4th '08 Flickr updated their script by adding a 1 px image which gets overwritten by the CSS above and messes up things. To fix it you need to add an 'a' element before the 'img'. So instead of #flickr img we now have to use #flickr a img. Because of the 1px image, all 4 Flickr thumbnails jump a bit lower in position, so I have to set the top padding of the #flickr div to 0 and adjust the height from 154 to 168 px (adding 14 px of the top padding).

That's just a tiny part of the template creation of my blog, but I promise we'll get deeper into this in my next post. So stay tuned ;)


43served

gravatar

1

permalink this comment Mark Bowen Fri Apr 14, 2006 at 08.16 am

Hiya Veerle,

Wow I’m the first to post!!!

Nice little tutorial there. I personally don’t use Flickr but am looking into possibly using it to store images online. Thanks for the tutorial on how to integrate it with EE using CSS. Fantastic!!

You are doing a fantastic job on this website and with each post you place on here it just keeps on getting better and better.

Can’t wait for the next installment in your EE series. I am looking at using EE for a site that I am going to be building as it seems to be the way to go if you ask me.

Once again, fantastic writing and thanks.

Best wishes,

Mark

X


gravatar

2

permalink this comment Janel Fri Apr 14, 2006 at 08.27 am

I have been wondering how that works thank you. I’ll mess with that tonight.
:)


gravatar

3

permalink this comment cristinamarie Fri Apr 14, 2006 at 08.42 am

My only gribe about it is that those who use the free version of Wordpress aren’t able to implment such fun and nifty things into their blog.


gravatar

4

permalink this comment Michel Fri Apr 14, 2006 at 09.15 am

Thank you, I’ve just searched for something like this.

My idea is to also put a <noscript> between the <script>-Tags with a link to the flickr-Account. It’s for the Users with JavaScript turned off and maybe an search engine.


gravatar

5

permalink this comment thomas Fri Apr 14, 2006 at 10.19 am

I wonder what people like about flickr so much, couldn’t you just as easily integrate a gallery in EE? or something like that..

Grts,
—Th


gravatar

6

permalink this comment John Topley Fri Apr 14, 2006 at 10.36 am

“My only gripe about it is that those who use the free version of Wordpress aren’t able to implment such fun and nifty things into their blog.”

Why not? I don’t see what’s stopped you.


gravatar

7

permalink this comment Nathan Smith Fri Apr 14, 2006 at 01.18 pm

Correct me if I’m wrong, but all versions of WordPress are free.

Nice write-up Veerle. Like you, I only use the actual script on my page. If anyone’s curious how I did the hover effects on my Flickr photos, you can check out the tutorial I wrote here.


gravatar

8

permalink this comment Emma Fri Apr 14, 2006 at 02.53 pm

Thanks so much for putting this guide up: I have been trying to work out how to do it ever since I saw your site!


gravatar

9

permalink this comment Rich Fri Apr 14, 2006 at 03.23 pm

Great stuff. It’s always nice to read how someone else does things.

John Topley: I assume they mean the wordpress.com service.


gravatar

10

permalink this comment Olav Fri Apr 14, 2006 at 07.15 pm

Thanks, very usefull! Flickr should link to this, or provide better badge creation.


gravatar

11

permalink this comment Ksauce Fri Apr 14, 2006 at 11.10 pm

Thanks a million Veerle. I thought I was the only one who couldn’t find it. I’m still exploring flicker to see what else they offer but this tutorial will help immensely. I just finished my flash portfolio if you’ve got some time take a look. Kurt Potts Digitalbook


gravatar

12

permalink this comment stephen Sat Apr 15, 2006 at 08.46 am

The best part of that instruction is the 4 images option. That isn’t explained over at flickr.com, only 3, 5 or more is given as an option. Thankfully the script can be easily modified.


gravatar

13

permalink this comment Kevin Hamm Sat Apr 15, 2006 at 09.58 am

Great write up, and a truly lovely site. I hate asking questions on why one technique is chosen over another as they usually sound snide, but I have such a question, and I’m absolutely not questioning you or trying to be a showman - just for clarification, since my maternal grandmother was 40-grit sandpaper.  =)

The use of the absolute positioning outside of the view-space is the thing - why use the position of the element instead of just using the display property? I would think that:

#flickr h2 {
display: none;
}

would have the same effect. Of course, I could still be so new that I think this works in more than Safari and the Mozilla hatchlings. I’ve got it working on a test blog that I’ve been working on, and it seems to be working in IE, although that could easily be a happy coincidence of another bug covering up this problem - I’ve had that happen, too.


gravatar

14

permalink this comment Veerle Sat Apr 15, 2006 at 10.17 am

@ Kevin Hamm: You are right that it works but the display none property is also being used for bad things to hide popular words for search engines and the possibility is very real that Google or any other engines will punish this behavior in the future. It doesn’t happen right now but there is a very real threat. So that’s why I use the - thing just to be safe. You have to see it like this: Google is like a text reader and if you use display none it might skip it in the future, and it could very well be skipped in a text reader too so that’s not good also.


gravatar

15

permalink this comment Kevin Hamm Sat Apr 15, 2006 at 11.01 am

I hadn’t considered that because I figured that any site using CSS rather than inline styles wouldn’t have to worry because the indexing of a page hadn’t progressed to the point where sub-pages and linked items, regardless of the type, don’t affect the indexing of a pages contents. Again, newbie, and I often presume the most reasonable to me, which is not always a reflection of anyone else’s reality at all.

If you had conflicting element styles in multiple CSS documents, all linked to the main page, how can that be reconciled? If in the ‘screen’ document you used the “display:none;” style but in the ‘print’ CSS document you used “font-size: 18px; color: #121298; background-image: url(print-background.png); background-repeat: no-repeat;” would the index create a weighted system, only consider one of the CSS documents, or perhaps do something else completely unexpected?


gravatar

16

permalink this comment Michel Sat Apr 15, 2006 at 11.12 am

Also, display: none; hides some screen readers to read the hidden content.


gravatar

17

permalink this comment Kevin Hamm Sat Apr 15, 2006 at 11.54 am

Responding to the display: none; being adversely used in screen readers: If the style was an inline style tag, a bit of the code of the HTML document, I would agree it was possible that this would be the case, but not probable for a couple of reasons.

First would be that screen readers in use today have logic in place to ignore much of the style tags used throughout non-semantic HTML. They have to, otherwise 90% of the reading would be ‘TABLE’, ‘TABLE ROW”, etc., which wouldn’t exactly lead to understanding. A good portion of that last 10% could easily be “COLOR, RED” and the like, given the horrible code out there. (myspace.com, I’m looking at you…)

But while that logic is in place to remove style tags from the text that gets read aloud, the screen-reader must also, to some extent, assess the table structure to understand the logical flow of the page and try to communicate that to the reader. So after it removes all the style tags except those that can be communicated verbally, like em and strong, why would it bother to assess the ‘display’ tag? And again, this is only true for non-semantic HTML documents.

Semantic (X)HTML linked to CSS for styles and structures is a different animal entirely. First, the HTML document’s code is easily read for content by humans, which is part of it’s wholesome goodness.  The screen reader wouldn’t read the CSS document at the same time it reads the HTML document, obviously - can you imagine the cacophony? - and I would wonder that it would even download the CSS document at all. Why bother? CSS is style and structure, two things that when removed won’t destroy the ability of the content to be understood.

And without downloading the CSS, it would never see the ‘display’ property setting, and would then read the ‘h2’ element along with the rest of the page just as it should. This would mean that Veerle’s blog pages would be visual and aural analogues, which is the point, right?

Given that the CSS is explicitly for style and structure, not content, it begs the question: Why would a program designed to remove style and structure in order to effectively communicate the content of an HTML document bother with the linked CSS at all? That seems beyond odd to me. Do they really do this?


gravatar

18

permalink this comment Bart Grzyb Sun Apr 16, 2006 at 08.18 am

Thx! Great little tutorial. I’ve used it on my homepage. Works flawless.


gravatar

19

permalink this comment Paul Stamatiou Sun Apr 16, 2006 at 07.12 pm

And this is why I like WordPress - flickrRSS.


gravatar

20

permalink this comment Joseph Mon Apr 17, 2006 at 12.28 pm

Wow. That seems cool but extremely complicated at the same time. I will try it though.


gravatar

21

permalink this comment nicole Mon Apr 17, 2006 at 12.51 pm

I wish I was brainy enough to make use of this info (though I thoroughly enjoyed reading the posts). Maybe I’ll be able to figure it out once I finish reading my magical CSS book? ;)


gravatar

22

permalink this comment Michael Holcomb Mon Apr 17, 2006 at 03.38 pm

That goes for google’s search form as well.  Took me near 20 minutes to get their code even XHTML transitional compliant.


gravatar

23

permalink this comment cesartorres.net Mon Apr 17, 2006 at 03.49 pm

WOW! And I thought I had a pretty cool web site. I was so mistaken. I keep my writing and other literary stuff at www.cesartorres.net, but after visiting your site, I am blown away. Not only do you have good content, luscious design and a good sense of humor, but your code is super clean and your styles divine.

I am flabberghasted. You are great. I will recommend this site to all my friends. I will even write about it in my site, www.cesartorres.net. GOOD JOB!


gravatar

24

permalink this comment Julian Bennett Holmes Mon Apr 17, 2006 at 04.09 pm

I’ve been using this for a while on my site (julianbh.com), and I’m wondering why you don’t make the tag self closing, like this:
<script ... /> instead of <script ...></script>


gravatar

25

permalink this comment Valter Tue Apr 18, 2006 at 02.14 am

@Julian about empty script elements: Compatibility. If some browser fails to recognise the syntax for empty elements it might just consider everything that follows as part of the script… not everyone out there reads XML fluently.

About XHTML and [removed]. I recall reading that using [removed] in XML documents is illegal or indeed impossible in a true XML context. Which means that the flickr badge scripts shouldn’t work in XHTML documents. Please prove me wrong!


gravatar

26

permalink this comment Veerle Tue Apr 18, 2006 at 03.48 am

@Valter: That’s what I like about my blog, my readers are always fast :) Thanks Valter for beating me to it with your very clear explanation, couldn’t have said it any better :o)


gravatar

27

permalink this comment Julian Bennett Holmes Tue Apr 18, 2006 at 09.27 am

Ah. Thanks.


gravatar

28

permalink this comment Jon Tue Apr 18, 2006 at 11.26 pm

Hi,

I just found this, right after asking you about the flickr photos on your site.  Thanks!


gravatar

29

permalink this comment AppleFlap Wed Apr 19, 2006 at 10.43 am

grrreat :)


gravatar

30

permalink this comment Dominik Lenk Wed Apr 19, 2006 at 02.32 pm

I saw this is the code that you provided:
<h2>Flickrness</h2>
After looking up to the flicker badge on your site, I wondered whether you have a trick to make the text appear vertical or whether you just use css, set display to none, and use a background image for your vertical heading. How did you do that? (Oh, and your site looks amazing!)


gravatar

31

permalink this comment Veerle Thu Apr 20, 2006 at 03.43 am

Dominik said:

After looking up to the flicker badge on your site, I wondered whether you have a trick to make the text appear vertical or whether you just use css, set display to none, and use a background image for your vertical heading. How did you do that?

I use CSS, in other words the vertical text is replaced with a background image in the #flickr div container. The text in the XHTML code doesn’t appear in my layout because I give the h2 a position outside the browser window (top:-300px and left:-300px). You can use display:none to hide elements or text but if there are other options I prefer those, because chances are that certain screen readers will also ‘skip’ text that has a display:none style and I don’t want that to happen.


gravatar

32

permalink this comment Mark Bowen Sat Apr 22, 2006 at 04.56 am

Hi Veerle,

You beat me to it with the answer, was exactly what I was going to say! I wanted to answer hoping that I was right as I wanted to try and help someone out for you to say thanks for all the hard work that you have put in to your site and for everything that you have given to everyone.

I know this isn’t exactly the right place to ask but I thought that someone might be able to help me with a little CSS quandary that I have. If I shouldn’t be asking in here then I apologize whole-heartedly and will understand if you need to delete this comment.

Could someone possibly take a look at this page - http://www.something2ad.com/test/H20_Page_Layout.html for me and with all your knowledge of CSS and EE possibly let me know how I would start to go about chopping it up for inclusion as maybe three templates for Expression Engine?

What I would like to be able to do is have a top header which will also include navigation buttons that will probably start underneath the left hand flag and then go across. I will then have the main white block in the middle and then the footer template. I’m thinking that I could probably (with a whole lot of work on my behalf!!) figure out most of it but it would probably take a long time (which I am prepared to do if needed) but the bit that is frustrating my head is the drop shadow. As I have faded out the shadow on the left and right sides and as I have no idea as to how long a page will be I was wondering if anyone had any clever ideas as to how I would know where AND how to place these in.

Please, as I said before, feel free to delete this post if I have been too forward in my questioning and I do apologize if I do offend anyone by asking in here it’s just that everyone is so helpful in here and I thought I would ask first.

Thank you for your time and efforts.

Best wishes,

Mark Bowen


gravatar

33

permalink this comment Mark Bowen Sat Apr 22, 2006 at 05.36 am

Hi Veerle,

Forgot to mention in the last post that when I tried to post an answer to Dominic that your site said to me that I couldn’t post again until I waited for the standard 600 seconds (5 minutes) but I hadn’t even been on your site for about a day (I know naughty me!! :D ).

Just thought I would let you know in case there is a problem with people being able to post.

These two have gone through fine but I had real problems when I was trying to post to Dominics query.

Just thought I should let you know. Don’t know if anyone else has had that problem at all?

Best wishes,

Mark


gravatar

34

permalink this comment dude Tue Apr 25, 2006 at 11.38 pm

u couldn’t do a tutorial on the flash badge could u?

i have been wanting to make the dimensions of the entire badge, and the individual components, i.e. the photos, bigger.

cheers

PS:  no speaky techy, but do speaky photographee…


gravatar

35

permalink this comment Veerle Wed Apr 26, 2006 at 11.21 am

dude said:

u couldn’t do a tutorial on the flash badge could u?

Flash is not my thing so sorry :(


gravatar

36

permalink this comment scott offord Wed Apr 26, 2006 at 08.18 pm

I got slammed for using negative positioning on my site. as soon as i removed the use of it, my site got higher in the google rankings again.
Scott


gravatar

37

permalink this comment Daniel Fri Apr 28, 2006 at 04.11 am

Just curious why you use padding to create the borders and not just use the border property on the image itself?

Lovely designed site by the way


gravatar

38

permalink this comment make money online Fri Apr 28, 2006 at 06.59 pm

Great article, that was interesting


gravatar

39

permalink this comment rAKeSH Mon May 1, 2006 at 04.51 am

Nice tutorial. I was going to write a similar tutorial. Actually i too made a similar badge for my blog based on an article in this link http://www.hicksdesign.co.uk/journal/flock-hickr


gravatar

40

permalink this comment Ryan Mon May 1, 2006 at 07.40 pm

Great little tutorial!  I’ve been using the Flickr badge for a while and hadn’t fixed the styles…you’re tutorial inspired me to get off my arse and fix it!

Thanks!


gravatar

41

permalink this comment Julian Bennett Holmes Tue May 9, 2006 at 02.08 pm

Why do browsers mess up on self closing [script] tags, but not on other self closing elements?


gravatar

42

permalink this comment Charles Thu May 18, 2006 at 06.20 am

I’m trying to implement a FLICKR-badge on a new site. A stupid question perhaps, but nevertheless : how could one adapt the flickr-script to have the pictures opening in a new window iso the same ?


gravatar

43

permalink this comment BillyWarhol Mon Jun 5, 2006 at 05.46 pm

thanks for sharing this useful & helpful info Veerle & the comments from yer readers as well!

;))



Commenting is not available on this article.

Flickrness

buy something from my Amazon wishlist