Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • @respectyoda Care to share what any of those are? It is nice to know you solved the problem but unfortunately you are very vague about what others like use need to do. Any specifics? Any links to help / doc files? Anything besides “Delete Mod rewrites in .htaccess file” would be apprecieated. Cheers.

    Thread Starter thorakmedichi

    (@thorakmedichi)

    Thanks. I can work with that. It shows both the “Appearance” and my new “Site Menus” items but I can at least drop the Appearance menu to the very very bottom of the list.

    PS I have the free version of your plugin. By the way I love it. Certainly makes my life easier than hard coding all this into the functions.php file like I did for ages.

    This seems to have been fixed as of the newest version I have installed (1.2.5.6) – just a heads up

    Thread Starter thorakmedichi

    (@thorakmedichi)

    Ok one more thing I just noticed. If I turn on ‘Enable Shipping’ but select ‘Only Ship to Billing Address’ then the problem goes away. So I guess the problem is a Javascript error related to having the Shipping Form active…

    As a side note I tried unchecking ‘Only ship to billing address’ and checking ‘Ship to billing address by default’. With these settings the both the forms are duplicating the postalcode.

    Any help would be appreciated.

    The site I am using this for is still under development so its all being run on a local server at the moment – so no link to share unfortunately. I will of course share it once the site goes live in about 3 weeks ??

    I still want to implement ImageMagick for it as well. So lets see who gets there first hahaha.

    I thought about doing this as a plugin addition to yours but I got lazy and just ‘hard-wired’ it in to the site. I wasn’t quite sure how all your code went together because I only had a day to mess around with it. It just means I cant update Meta Slider now haha. Oh well. Just dont do any major changes on me before you implement it yourself.

    ImageHelper would be the hardest one to implement with an add on plugin. I just couldn’t think of anyway to manipulate it without writing to your core file… unless of course you add an if (! function ){} wrapper – then I could maybe do an over-ride in functions.php. Again, haven’t spent to much time on it because I didn’t want to get too buried into figuring out your entire code setup.

    If you feel the need to break out of this forum for further discussions please feel free to email me directly at [email protected] . I would be willing to try and assist with things when / as I find time.

    Hey Tom,

    Just an update in case you are interested. I got this working for GD. I am sure it would be quite simple for ImageMagick as well by applying the same theory.

    Just so you know what I did to get it to work on my site. It is far from polished per se but its a good starting point at least for you ??

    Keep in mind what I have added to my functions.php file and as the include file could be incorporated into your own plugin instead. I was just trying to stay out of it as much as possible in case you publish any other updates.

    File adjustments:

    my functions.php

    function rs_add_scale_to_image_editor( $editors ) {
    	if( ! class_exists( 'WP_Image_Editor_Scale' ) )
    		include( 'inc/image-editor-scale.php' );
    
    	array_unshift( $editors, 'WP_Image_Editor_Scale' );
    	return $editors;
    }
    add_filter( 'wp_image_editors', 'rs_add_scale_to_image_editor' );

    new file saved in my theme/inc/ folder image-editor-scale.php

    class WP_Image_Editor_Scale extends WP_Image_Editor_GD {
    
    	public function hex2rgb($hex) {
    			   $hex = str_replace("#", "", $hex);
    
    			   if(strlen($hex) == 3) {
    				  $r = hexdec(substr($hex,0,1).substr($hex,0,1));
    				  $g = hexdec(substr($hex,1,1).substr($hex,1,1));
    				  $b = hexdec(substr($hex,2,1).substr($hex,2,1));
    			   } else {
    				  $r = hexdec(substr($hex,0,2));
    				  $g = hexdec(substr($hex,2,2));
    				  $b = hexdec(substr($hex,4,2));
    			   }
    			   $rgb = array($r, $g, $b);
    			   //return implode(",", $rgb); // returns the rgb values separated by commas
    			   return $rgb; // returns an array with the rgb values
    	}
    
    	public function scale ( $max_w, $max_h, $color ) {
    
    			// Get the current image size
    			$size	= $this->size;
    			$src_w 	= $size['width'];
    			$src_h 	= $size['height'];
    
    			/* Lets do some math that is needed for scaling and placing the resized image
    			 *****************************************************************************/
    
    			// Set our defaults for either max height or max width
    			$new_w		= $max_w;
    			$new_h 		= $max_h;
    			// Set our defaults for where to place the resized image in the new image
    			$align_w	= 0;
    			$align_h 	= 0;
    
    			// Determine if the image is landscape or portrait
    			if( $src_w > $src_h ){
    				$ratio = $src_h / $src_w;
    				$new_h = (int)round($new_w * $ratio); // Proportionatly Scale height of image to fit MAX frame
    				$align_h = ($max_h - $new_h) / 2; // Center resized image in new image
    
    				// Double check that the new dimensions dont break the containers height restrictions
    				if ( $new_h > $max_h ){
    					$new_h = $max_h; // Set the height of the image to the max height of the container
    					$new_w = (int)round($new_h / $ratio); // Determine new width to make image fit max height
    					$align_h = 0; // Its full height so align to top
    					$align_w = ($max_w - $new_w) / 2; // Center across the width
    				}
    
    			}else{
    				$ratio = $src_w / $src_h;
    				$new_w = (int)round($new_h * $ratio); // Proportionatly Scale width of image to fit MAX frame
    				$align_w = ($max_w - $new_w) / 2; // Center resized image in new image
    			}
    
    			/*****************************************************************************/
    
    			// Create a new image based on the max dimensions provided
    			$scaled_image = wp_imagecreatetruecolor( $max_w, $max_h );
    
    			if ( function_exists( 'imageantialias' ) )
    				imageantialias( $scaled_image, true );
    
    			// Convert the users hex value to RGB
    			$rgb = $this->hex2rgb ( $color ); 
    
    			// Color the image background
    			$color = imagecolorallocatealpha ( $scaled_image , $rgb[0] , $rgb[1] , $rgb[2] , 0 );
    			imagefilledrectangle( $scaled_image, 0, 0, $max_w, $max_h, $color);
    
    			// Copy the old image, scale it to fit proportionatly into the new image with no cropping
    			$old_image = imagecreatefromjpeg($this->file);
    			imagecopyresampled  ( $scaled_image, $old_image, $align_w, $align_h, 0, 0, $new_w, $new_h, $src_w, $src_h);
    
    			// Update WP and finish
    			if ( is_resource( $scaled_image ) ) {
    				imagedestroy( $this->image );
    				$this->image = $scaled_image;
    				$this->update_size();
    				return true;
    			}
    
    			return new WP_Error( 'image_scale_error', __('Image crop failed.'), $this->file );
    	}
    }

    Edits to your files:

    metaslider.imagehelper.class.php

    added private $color; to opening declarations
    added $this->color = $color; to your __construct
    commented out the following lines in your ‘resize_image’ function

    /*
    		$dims = image_resize_dimensions($orig_size['width'], $orig_size['height'], $dest_size['width'], $dest_size['height'], true);
            if ($dims) {
                list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
                $image->crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h);
            }
    		*/

    added $image->scale( $this->container_width, $this->container_height, $this->color ); in place of the commented lines

    By just adding the above lines the image will always have a black background. If you want users to enter a custom value without editing code then the follow has to be added / changed in your plugin itself.

    ml-slider.php
    added this to your ‘render_admin_page’ function after height and width

    'color' => array('priority' => 25, 'type' => 'text', 'size' => 6, 'value' => $this->slider->get_setting('color') == 'false' ? 'FFFFFF' : $this->slider->get_setting('color'), 'label' => __("BG Color", "metaslider"), 'class' => 'coin flex responsive nivo', 'helptext' => __("Slideshow background color", "metaslider"), 'after' => __("", "metaslider") ),

    metaslide.image.class.php
    adjusted all the ‘new MetaSliderImageHelper()’ calls to include ‘color’ option (either $settings['color'] or $this->settings['color']

    I hope that helps you or anyone else looking into this idea.

    Cheers
    Ryan

    Given that the WP Media Manager uses both GD Lib and ImageMagick could you not use them to simply resize the image and add a colored background based on a user selection in the admin controls? I don’t think it would be hard to setup at all. In fact I am going to take a look at hacking your plugin to do just that… the only problem is if you ever do an update I will lose my hack – unless you can point me towards any hooks you use that I can tap into from the functions.php file.

    Thread Starter thorakmedichi

    (@thorakmedichi)

    So it turns out that even though I am creating a TEMPORARY table wordpress will store those results for a period of time. Therefore doing something as simple as this:

    $SQL1 = "CREATE TEMPORARY [...] LIMIT 0, 500";
    $SQL2 = "SELECT *, ROUND[...] LIMIT 0, 200";
    
    $wbdb->query($SQL1);
    $wbdb->query($SQL2);

    Will work.

    Thread Starter thorakmedichi

    (@thorakmedichi)

    Hey Mike thanks for the replies. The first link just says that its an issue with PHP and leads me nowhere per se – but it does mention I just may not be able to do this at all.

    The second link using a UNION was a great lead – but doesn’t work in my case because it is not multiple SELECT statements. I am trying to create a temp table and then select more advanced information from it.

    It looks like I need to use something like the UNION to rebuild this query but not sure what. Any SQL masters out there??

    None the less both great ideas. Cheers

    Thread Starter thorakmedichi

    (@thorakmedichi)

    It was an issue with my custom taxonomy it seems. NVM

    Thread Starter thorakmedichi

    (@thorakmedichi)

    I should add that I know I can do this dynamically when the image displays but given the amount of images loading at once I think that going that approach is far more server intensive than just creating them on upload.

Viewing 11 replies - 1 through 11 (of 11 total)