Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*Call the Extra Thumbails */
- function makethumburl($url, $delete = false){
- //This function has 2 uses: 1. to rejig the image url to call the thumbnail sized version of the image. 2. The remove the file extension so the image can be compared to the thumbail already called.
- $exts = array('.jpg','.jpeg','.png','.gif');
- foreach($exts as $ext){
- if(strpos($url,$ext)){
- $theext = $ext;
- }
- }
- if ($delete == true ) {$replacer = '';} else {$replacer = '-38x38' . $theext;}
- return substr_replace($url, $replacer, (strlen($theext)*-1), strlen($theext));
- }
- $i=1;
- //We now query the database directly to obtain the attached images.
- $query = 'SELECT *
- FROM `wp_posts`
- WHERE `post_parent` = "' . wpsc_the_product_id() .'"
- AND `post_type` = "attachment"';
- $result = mysql_query($query);
- while($row = mysql_fetch_array($result)){
- $image_url = $row['guid'];
- if ( strpos(wpsc_the_product_image(), makethumburl($image_url, true)) === false ) //Checks if the image has already been called earlier as product thumbnail.
- {
- ?>
- <a href="<?php echo $image_url; ?>" rel="lightbox[<?php echo wpsc_the_product_id(); ?>]">
- <img src="<?php echo makethumburl($image_url); ?>" width="36px" height="36px" alt="<?php echo wpsc_the_product_title() . ' ' . $i; ?>"/>
- </a>
- <?php
- $i++;
- }
- }
- /*END - Call the Extra Thumbails */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement