FEN Reader WordPress Plugin
Note: You are viewing a page off my vegan food blog as it was the most convenient for me.
This WordPress plugin enables easy display of a chess position, and information pertaining to its current state, using Forsyth-Edwards Notation (FEN), part of the Portable Game Notation (PGN) standard, by embedding it within the special HTML tags <fen> and </fen>.
The FEN standard is described at Wikipedia thusly:
A FEN record contains 6 fields.
The separator between fields is a space.The fields are:
1. Piece placement (from white’s perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file a through file h. White pieces are designated using upper-case letters (”KQRBNP”), Black by lowercase (”kqrbnp”). Blank squares are noted using digits 1 through 8 (the number of blank squares), and “/” separate ranks.
2. Active color. “w” means white moves next, “b” means black.
3. Castling availability. If neither side can castle, this is “-”. Otherwise, this has one or more letters: “K” (White can castle kingside), “Q” (White can castle queenside), “k” (Black can castle kingside), and/or “q” (Black can castle queenside).
4. En passant target square in algebraic notation. If there’s no en passant target square, this is “-”. If a pawn has just made a 2-square move, this is the position “behind” the pawn.
5. Halfmove clock: This is the number of halfmoves since the last pawn advance or capture. This is used to determine if a draw can be claimed under the fifty move rule.
6. Fullmove number: The number of the full move. It starts at 1, and is incremented after Black’s move.
Examples
<fen></fen> displays the starting position:
White can castle kingside or queenside.
Black can castle kingside or queenside.
There are no en passant captures possible.
The last capture or pawn advance was 0 half-moves ago.
Position at move 1.
<fen>
r2qk2r/ppp1bppp/3p4/4n2n/2B1P1b1/2NPBN2/PPP3PP/R2Q1RK1
w kq - 7 9
</fen> gives:
Black can castle kingside or queenside.
There are no en passant captures possible.
The last capture or pawn advance was 7 half-moves ago.
Position at move 9.
Usage Tips and Tricks
The above is about as much fragmentation as the <fen> tags can handle. The FEN specification requires spaces betwen the fields, but I tried to allow for other whitespace characters or separators.
You may exclude further information from display by leaving off the unwanted fields in the FEN. For example,
<fen>r2qk2r/ppp1bppp/3p4/4n2n/2B1P1b1/2NPBN2/PPP3PP/R2Q1RK1 w</fen> would display only the above diagram and the White To Move text.
If you wish to create a 10×10+ board, which I believe is unsupported by FEN anyway, and have a rank with more than 9 empty squares, you will need to enter them as back-to-back single digits adding up to the desired number. For example, “/82/” within the piece placement field will display a rank with 10 empty squares.
Installation
Unzip fen-reader.zip and upload the contained fen-reader.php file to your wp-content/plugins directory.
Create a directory on your website and populate it with the images in this zip file, originally from http://andstuff.org/chess.
From your Plugins menu, activate FEN Reader.
From your Options menu, enter the URL to the just created image directory.
Enjoy!






































September 7th, 2006 at 1:42 pm
Like it a lot. Congratulations.
September 8th, 2006 at 11:48 pm
Thanks, Leonardo. By the way, I have added an interactive form here, so you can play around with entering positions in FEN and viewing the results.
September 21st, 2006 at 9:05 pm
Erin, I’m having a problem with the plugin. Everytime I change the location of the pieces (the png files), the plugin just don’t change the URL. It keeps my root URL, that is blogueisso.com. Any idea how to fix it?
September 21st, 2006 at 11:00 pm
Thank you for trying my plugin and reporting this situation. I have patched it up. Please download again, and let me know if the issue has been resolved.
September 22nd, 2006 at 9:18 pm
Erin, now it’s perfect. Thanks. I will send the link where I will use it later.
September 22nd, 2006 at 9:38 pm
Look, it’s cool.
Thanks again.
September 22nd, 2006 at 9:42 pm
Sweet!
I’m so glad someone is getting good use out of it. Thanks for letting me know.
November 6th, 2006 at 5:22 am
Hello, it lowers your plugin, it is very good, but I have had a problem, it installs it and the board leaves to me very wide, and between each piece there is a slight space, since I do to him so that it is like the one of your blog, I do not explain or that becomes the board great, I have not moved him anything to I cosay. Greetings and thanks. p.d. my english is not very good
November 6th, 2006 at 9:26 pm
I am not sure what advice to offer about this situation. The plugin generates a basic html table. There is no space purposely placed between the pieces.
Does this only happen with a certain FEN? If so, you could try entering it here to see if it looks any better? Either way, if it is specific to a particular FEN string, please post the culprit.
Does it affect the display by altering the fonts or resizing your browser or area in which the board is situated?
Sorry to not be of greater assistance. Maybe a fellow plugin user has some additional thoughts?
November 7th, 2006 at 7:20 am
The problem is the theme. Somewhere in the css of your theme you have something that causes the spaces.
November 10th, 2006 at 9:39 pm
Thank you, Tomas, for your additional, erudite, suggestion. It seems he has it working now (click on Ramon’s name to be taken to his blog).
May 25th, 2007 at 10:46 am
For some reason the wp 2.13 will not allow me to change the path for the graphics for this fen reader - is there a place in the code that will aallow me to hard code the png path?
Thanks
May 25th, 2007 at 10:55 am
In fen-reader.php, in the render_position function,
replace
$image_url = get_option( ‘fen_reader_images’ );
with
$image_url = ‘http://www.mysite.com/image_dir/’;
where, of course, the URL given is just an example.
(Note also, the trailing slash is important.)
May 26th, 2007 at 12:03 pm
Thanks, that worked great.
October 15th, 2007 at 9:10 am
It would be nice if you gave the table its own class, so it can be defined in the stylesheet by itself
.fen {
margin: 0px;
border: 0px;
}
and not a hack like
.text center td img {
margin: 0px;
border: 0px;
}
Because it is not impossible that I would like another image in a table which is centered, but with the default style (which has a margin and a border).
October 15th, 2007 at 9:21 am
btw, the way you generate the table is not correct, the use of a single cell works, but it should at least be defined inside its own row (). It only works because modern browsers are build to parse even the most crappy HTML (yes there is worse ;)).
The best way would be to generate a table with 8 rows and each row with 8 cells and let the user define the borders, alignment, spacings and all that using a stylesheet.
October 15th, 2007 at 9:23 am
Peter, Peter.
I reckon you are probably right with your helpful suggestions. Thank you. I knew even less about CSS and HTML standards then.