Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Image dimensions in X_Threads
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Image dimensions in X_Threads
I am busy going through the LeeFish pages trying to optimise them a bit and I have a bit of a problem with image sizes from XThreads when used in a plugin.

The XThreads images have a nifty feature where you can set the width and height for thumbnail images without "breaking" the image proportions. I have this set up in all threads where I display XThread images (got me one point more on the page speed test Smile ) but I am unsure how to apply this image resizing feature to plugins that call the image.

Here is an example plugin query:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$query = $db->query("
	SELECT a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, a.field, t.*
	FROM ".TABLE_PREFIX."xtattachments a
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
	WHERE t.visible=1 AND a.field='pfpic' AND t.closed NOT LIKE 'moved|%' AND t.fid IN ('".implode("','", $gallery_tid_array)."')
	ORDER BY t.tid DESC
	LIMIT 1
");
while($gallery = $db->fetch_array($query))
{
	$gallery_username = htmlspecialchars_uni($gallery['username']);
	$gallery_title = htmlspecialchars_uni($gallery['subject']);
	$gallery_postlink = get_thread_link(intval($gallery['tid']));
	$gallery_datetime = my_date($mybb->settings['dateformat'], $gallery['uploadtime']).' '.my_date($mybb->settings['timeformat'], $gallery['uploadtime']);
	$gallery_att_thumb = xthreads_get_xta_url($gallery).'/thumb160x120';

eval("\$gallery_gallery_gallery .= \"".$templates->get("gallery_gallery_gallery")."\";"
);
}


Where would I need to modify that query to be able to return the height and width? Not as fixed values as that would distort the thumb, but using the variable values as in the threadfields?


This is how I have it set up in my custom threadfields:

HTML Code
<a href="{URL}"><img src="{URL}/thumb160x120" alt="{$thread['subject']} Screenshot" title="{$GLOBALS['threadfields']['pfapicdesc1']}" width="{$GLOBALS['threadfields']['pfapic1']['thumbs']['160x120']['w']}" height="{$GLOBALS['threadfields']['pfapic1']['thumbs']['160x120']['h']}" style="border: 1px solid #C1C1C1; padding: 3px; margin: 3px;"  /></a>



[Image: leelink.gif]
MYBB1.6 & XThreads
02-25-2011 05:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Image dimensions in X_Threads
Add "a.thumbs" to the select list, and use something like:

PHP Code:
		if($gallery['thumbs'])
			$gallery['thumbs'] = unserialize($gallery['thumbs']);


My Blog
02-26-2011 11:30 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Image dimensions in X_Threads
Hmm, Zinga, I think I may be thick - I can't work out where to put the IF statement above.......

Please can you give a slightly bigger hint?

What I have done is this:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$query = $db->query("
			SELECT a.updatetime, a.md5hash, a.thumbs, a.uploadtime, a.aid, a.attachname, a.filename, a.field, t.*
			FROM ".TABLE_PREFIX."xtattachments a
			LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
			WHERE t.visible=1 AND a.field='pfpic' AND t.closed NOT LIKE 'moved|%' AND t.fid IN ('".implode("','", $gallery_tid_array)."')
			ORDER BY t.tid DESC
			LIMIT 1
		");
		
		while($gallery = $db->fetch_array($query))
		{
			$gallery_username = htmlspecialchars_uni($gallery['username']);
			$gallery_title = htmlspecialchars_uni($gallery['subject']);
			$gallery_postlink = get_thread_link(intval($gallery['tid']));
			$gallery_datetime = my_date($mybb->settings['dateformat'], $gallery['uploadtime']).' '.my_date($mybb->settings['timeformat'], $gallery['uploadtime']);
			$gallery_thumb = xthreads_get_xta_url($gallery).'/thumb160x120';	
			if($gallery['thumbs'])
			{
			$gallery['thumbs'] = unserialize($gallery['thumbs']);
			}
			eval("\$gallery_gallery_gallery .= \"".$templates->get("gallery_gallery_gallery")."\";");
			
		}


My images display ok (just like they did before) but the image dimensions are not applied (i.e. when I look in page speed it still says no image dimensions specified). Do I need to change something in the HTML template?



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 02-28-2011 05:49 PM by leefish.)
02-28-2011 03:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Image dimensions in X_Threads
I think you need to add the width and/or height array to the images tag (if you didn't do it).

03-01-2011 05:35 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Image dimensions in X_Threads
You mean like with the Globals threadfields? Otherwise it will just deform my images....


[Image: leelink.gif]
MYBB1.6 & XThreads
03-01-2011 07:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Image dimensions in X_Threads
Something like this:

HTML Code
<img ........ width="{$gallery['thumbs']['160x120']['w']}" height="{$gallery['thumbs']['160x120']['h']}" />


Or you can add the code in your plugin.

Edit:
1,000 posts Biggrin


(This post was last modified: 03-01-2011 08:15 AM by RateU.)
03-01-2011 08:05 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Image dimensions in X_Threads
Yay that worked - thank you RateU.

NOW I need the stupid post icons and smilies to accept a width and height.... my post on MYBB has not really had an answer I can get to work.

Hmm


[Image: leelink.gif]
MYBB1.6 & XThreads
03-01-2011 06:37 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Image dimensions in X_Threads
What have you done with the post icons and smilies?

03-02-2011 02:00 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Image dimensions in X_Threads
well, I tried changing the img src settings in /inc/functions_post.php and /inc/class_parser.php, as in this post here:

http://community.mybb.com/thread-88946.html


But it had no effect :/


[Image: leelink.gif]
MYBB1.6 & XThreads
03-02-2011 04:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #10
RE: Image dimensions in X_Threads
Not quite sure, but I think there is a "dirty" way to do that (if you are OK with the dirty way).

03-02-2011 04:22 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: