phpthumb speed

More
10 years 5 months ago #52165 by iamrobert
phpthumb speed was created by iamrobert
I am looking for some advice on speeding up a site.

The site is quite image heavy:

www.brassmonkeytaipei.com/

As it uses phpthumb to generate the images - I am thinking this could slow it down.

Now - I have increased the cache size to 3gb - but it doesn't seem to make much of a difference. The site also uses cloudflare ( www.cloudflare.com/ ).

Unfortunately because the images follow this format:
Code:
/phpThumb.php?src=myimage.jpg&w=100&h=100
they can't be served from cloudflare.

Now - I have been reading:
mrphp.com.au/blog/image-cache-us ... modrewrite

I am thinking that if you use modrewrite to rewrite it -
cloudflare could serve the image. Has anyone tried this approach?

Thanks,

Robert

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #52168 by ggppdk
Replied by ggppdk on topic phpthumb speed
Hello


-- in such cases it is best to use 1 of the fixed thumbnail sizes of the image/gallery field,

these are only calculated once

where do you use phpThumb ? in the universal module ?
there is parameter to use one of the fixed sizes of the image field.


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #52169 by iamrobert
Replied by iamrobert on topic phpthumb speed
Thanks for the answer.

I use it two ways:

1. Universal Module
Code:
<img <?php echo $force_height_feat." ".$force_width_feat; ?> src="<?php echo $item->image; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" />

2. Category:
Code:
<?php if ($this->params->get('lead_use_image', 1)) : if (!empty($img_field_name)) : FlexicontentFields::getFieldDisplay($items[$i], $img_field_name, $values=null, $method='display'); $img_field = & $items[$i]->fields[$img_field_name]; $src = str_replace(JURI::root(), '', @ $img_field->thumbs_src[$img_field_size][0] ); else : $src = flexicontent_html::extractimagesrc($items[$i]); endif; $RESIZE_FLAG = !$this->params->get('lead_image') || !$this->params->get('lead_image_size'); if ( $src && $RESIZE_FLAG ) { // Resize image when src path is set and RESIZE_FLAG: (a) using image extracted from item main text OR (b) not using image field's already created thumbnails $w = '&amp;w=' . $this->params->get('lead_width', 200); $h = '&amp;h=' . $this->params->get('lead_height', 200); $aoe = '&amp;aoe=1'; $q = '&amp;q=95'; $zc = $this->params->get('lead_method') ? '&amp;zc=' . $this->params->get('lead_method') : ''; $ext = pathinfo($src, PATHINFO_EXTENSION); $f = in_array( $ext, array('png', 'ico', 'gif') ) ? '&amp;f='.$ext : ''; $conf = $w . $h . $aoe . $q . $zc . $f; $base_url = (!preg_match("#^http|^https|^ftp#i", $src)) ? JURI::base(true).'/' : ''; // old $thumb = JURI::base(true).'/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src='.$base_url.$src.$conf; $thumb = JURI::base(true).'/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src='.$src.$conf; $thumbx = JURI::base(true).'/images/bm.jpg'; } else { $thumb = $src; } endif; ?>
Code:
<img src="<?php echo $thumb; ?>" alt="<?php echo htmlspecialchars($items[$i]->title, ENT_COMPAT, 'UTF-8'); ?>" />

Is this the best way?

Please Log in or Create an account to join the conversation.

More
10 years 5 months ago #52188 by ggppdk
Replied by ggppdk on topic phpthumb speed
Hello

both of them have parameter to use the thumbnails produced already by the image-gallery field:

small
medium
large

without using phpThumb to resize !!

see our performance guide:
www.flexicontent.org/documentati ... mance.html


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
10 years 4 months ago #52698 by iamrobert
Replied by iamrobert on topic phpthumb speed
Hi Ggppdk,

What we were finding was that when we load lots of images - and fields - it adds loads of queries to the database. So - the initial loading time for first byte was 1.8 seconds.

If we hardcode in the fields in our mod_flexicontent template file it cuts the number of db queries down substantially - from 285 to 116 queries and 42mb to 25mb memory usage.

So - consequently the page is faster:
www.brassmonkeytaipei.com/bmx/

I realize this won't work for everyone - but its cut our loading time by 2 seconds.
Code:
<?php $db =& JFactory::getDBO(); $db->setQuery("SELECT field_id, value FROM #__flexicontent_fields_item_relations Where item_id=".$item->_row->id); $itemdata = $db->loadObjectList(); foreach($itemdata as $bws_field){ // IMG if($bws_field->field_id ==25){ $item_value = unserialize($bws_field->value); } // TITLE CHN if($bws_field->field_id ==15){ $item->_row->fieldvalues[15][0] = $bws_field->value; } //SUBTITLE ENG if($bws_field->field_id ==34){ $item->_row->fieldvalues[34][0] = $bws_field->value; } //SUBTITLE CHN if($bws_field->field_id ==38){ $item->_row->fieldvalues[38][] = $bws_field->value; } } $bws_url = JURI::base().'images/flexicontent/s_'.$item_value['originalname']; ?>
Code:
<?php if ($mod_link_image_feat) : ?> <img <?php echo $force_height_feat." ".$force_width_feat; ?> src="<?php echo $bws_url; ?>" alt="<?php echo flexicontent_html::striptagsandcut($item->fulltitle, 60); ?>" /> <?php endif; ?>

Thanks,

Robert

Please Log in or Create an account to join the conversation.

More
10 years 4 months ago #52699 by ggppdk
Replied by ggppdk on topic phpthumb speed
Hello

in case that you have many images but you have disk space

- you can also increase phpThumb cache size (now default is 100MB only)
- you can increase the expire time (now it is 30 days)

this way the thumbnails will not be recalculated when any of the 2 above is reached


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.632 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save