I don't know if anybody can help me with this or if it even goes here, so please, if it doesn't belong here, just move it or let me know and I'll do it :3
Well, the thing is, I have simpleportal installed on my forum, I want to change the arrangement of the portal page, what i want to do exactly is to align the pictures to the left, which I've already accomplished, and instead of calling all the pictures, I just want to call the first picture in the post, I believe this can be done by configuring the javascript document that comes with simpleportal, wich has a few settings for the images, the thing is that I've got absolutely no clue about javascript...
Although I've been "playing" with the .js for a little while, I haven't got far before hitting a wall, so maybe a kind soul with some knowledge about javascript can give me a hand, here's the .js code in question:
function sp_image_resize()
{
var possible_images = document.getElementsByTagName("img");
for (var i = 0; i < possible_images.length; i++)
{
if (possible_images[i].className != (portal_smf_version == 1.1 ? "sp_article" : "bbc_img sp_article"))
continue;
var temp_image = new Image();
temp_image.src = possible_images[i].src;
if (temp_image.width > 300)
{
possible_images[i].height = (300 * temp_image.height) / temp_image.width;
possible_images[i].width = 300;
}
else
{
possible_images[i].width = temp_image.width;
possible_images[i].height = temp_image.height;
}
}
if (typeof(window_oldSPImageOnload) != "undefined" && window_oldSPImageOnload)
{
window_oldSPImageOnload();
window_oldSPImageOnload = null;
}
}
For what I've read online, seems like I need to create an array, however the arrays that I've seen so far require that you specify a specific name or an url, instead, I want to call the first picture of the post.
Here's a post that explains more or less what I want to do, except because I don't know how to add all that to the javascript, since I tried doing exactly what its said on the post and it didn't work, but that's basically the main idea, I'm guessing that the array will need to have the following codes:
// search <img> in $row['body']
$find = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $row['body'], $value);
// find src="" value.
if(!empty($value[0]) && !empty($value[1]))
$first_image = $value [1] [0];
else{ // if message don't have picture, just show it default image
$first_image = "http://www.site.com/images/default.jpg";
}
and
function temizle($haber) {
$strs=explode('<',$haber);
$res=$strs[0];
for($i=1;$i<count($strs);$i++)
{
if(!strpos($strs[$i],'>'))
$res = $res.'<'.$strs[$i];
else
$res = $res.'<'.$strs[$i];
}
return strip_tags($res);
}
So with all this said, please give me a hand :3