SMF Support > SMF 2.0.x Support
Simpleportal Javascript Question
(1/1)
mane16:
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, 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:
--- Code: ---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;
}
}
--- End code ---
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 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:
--- Code: ---// 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";
}
--- End code ---
and
--- Code: ---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);
}
--- End code ---
So with all this said, please give me a hand :3
Masterd:
This is not a place for asking mod's related questions. However, I think you'll find this topic rather helpful.
mane16:
--- Quote from: Masterd on June 27, 2012, 11:05:18 AM ---This is not a place for asking mod's related questions. However, I think you'll find this topic rather helpful.
--- End quote ---
thanks for the tip, I wasn't absolutely sure where this post might belong...
I'll take a look at the post and maybe somebody has asked the same question I have and it can help me, I hope...
thanks again :3
Navigation
[0] Message Index
Go to full version