You could hard code it, which looks to be how they've done it. Either that or something server side because if javascript is disabled the embed code is still there. Essentially:
HTML Code:
<td height="160" align="left" valign="top"><span class="simplebody_big_bold_caps">Embed Code</span>:<br />
<input name="embed_code2" type="text" class="embedField marginBottom45" id="embed_code2"
value='<a href="http://www.charitywater.org/whywater"><img src="http://www.charitywater.org/media/banners/468x60_8glasses.jpg" width="468" height="60" border="1" style="border-color: #CCC"/></a>'
size="28" /></td>
Javascript could be used, but then the embeds wouldn't be available to non-javascript users. Converting all those <, >, and quote characters to their HTML entity equivalents can be easily done in PHP though, so that might be being used. See:
http://www.php.net/manual/en/functio...ecialchars.php
Example (Note - PHP requires a PHP enabled server):
PHP Code:
<?php
$isrc = 'http://www.charitywater.org/media/banners/468x60_8glasses.jpg';
$image = '<img src="' . $isrc . '" width="468" height="60" border="1" style="border-color: #CCC"/>';
$embed = '<a href="http://www.charitywater.org/whywater">' . $image . '</a>';
echo $image;
echo '<br>';
echo '<input type="text" value="' . htmlspecialchars($embed) . '" size="28">';
?>
They also have javascript to select the embed code on click, but that's not working because the text inputs containing the embed code are not part of a form and the code to select them assumes that they are. Even if they were, that code is incorrect though and as a result would select the wrong embed code in most cases.
Here's a more elaborate PHP approach, one that can take any number of images of varying sizes that also has a corrected javascript for selecting the embed code:
PHP Code:
<?php
$images = array(
'someimage.jpg' => 'width="40" height="100"',
'anotherimage.jpg' => 'width="80" height="75"',
'thirdimage.jpg' => 'width="60" height="120"'
);
$relpath = 'images/';
$abspath = 'http://www.somedomain.com/images/';
$link = '<a href="http://www.somedomain.com/">';
$output = array();
foreach ($images as $src => $dims){
$imgsuffix = ' ' . $dims . ' border="1" style="border-color: #CCC"/>';
$image = '<img src="' . $relpath . $src . '"' . $imgsuffix;
$embed = $link . '<img src="' . $abspath . $src . '"' . $imgsuffix . '</a>';
array_push($output, $image, '<span>Embed Code:</span>',
'<input type="text" value="' . htmlspecialchars($embed) . '" onfocus="this.select();" size="28">'
);
}
echo implode("<br>\n", $output);
?>
Bookmarks