Klan1 Common WP Functions

Klan1 Common WP Functions

from 0$

Klan1 Common WP Functions is a Package Installer from the Open Source WP Plugins range Basic functions needed by our others plugins and templates.

For more information about a tailored Package Installer like Klan1 Common WP Functions please contact us directly.

This functions are for those needs to resize images on their templates or plugins all the time.

FUNCTION: k1_get_post_thumb_url

DESCRIPTION

string k1_get_post_thumb_url(int $post_id)

This function return the URL for the FEATURED IMAGE (full sized) defined in a POST/PAGE even if the upload is no on the actual post. If is not defined returns the FIRST image if there is at least one.

Returns NULL if no jpg,png or gif images as attachments.

USAGE EXAMPLE

<?php echo k1_get_post_thumb_url($post_id); ?>

PARAMETERS

  • $post_id If is empty, we will try to get the POST ID from the global $post var

FUNCTION: k1_get_post_timthumb_img_url

DESCRIPTION

string k1_get_post_timthumb_img_url(int $post_id, int $width, int $height, int $crop, char $align, int $quality)

Returns the IMAGE full URL using timthumb script to resize the post featured image. Use this when you only need the URL not the IMG html tag.

USAGE EXAMPLE

<?php echo k1_get_post_timthumb_img_url(null, 80, 50, 1, "t", 50); ?>

PARAMETERS

  • $post_id If is empty, we will try to get the POST ID from the global $post var
  • $width This is numeric in pixels, if you use 0 width will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
  • $height This is numeric in pixels, if you use 0 height will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
  • $crop Use: 0 Resize to Fit specified dimensions (no cropping), 1 Crop and resize to best fit the dimensions (default), 2 Resize proportionally to fit entire image into specified dimensions, and add borders if required, 3 Resize proportionally adjusting size of scaled image so there are no borders gaps, see: http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
  • $align c : position in the center (this is the default), t : align top, tr : align top right, tl : align top left, b : align bottom, br : align bottom right, bl : align bottom left, l : align left, r : align rightSee: http://www.binarymoon.co.uk/2010/08/timthumb-part-4-moving-crop-location/
  • $quality 70 : Image quality from the original uploaded image in percentage

NOTE: If you just define one height or width as zero (0) the other one will conserve image proportion, if is not defined it will be default value.

FUNCTION: k1_get_post_thumb_img_html

DESCRIPTION

string k1_get_post_thumb_img_html(int $post_id, boolean $resize, int $width, int $height, int $crop, char $align, int $quality)

This function returns the FULL IMG HTML tag for the post featured image using TIMTHUMB or not as desired

USAGE EXAMPLE

<?php echo k1_get_post_thumb_img_html(null, true, 80, 50, 1, "t", 50); ?>

PARAMETERS

  • $post_id If is empty, we will try to get the POST ID from the global $post var
  • $resize TRUE to use timthumb script to resize the image, FALSE to return the image without any dimension change.
  • $width This is numeric in pixels, if you use 0 width will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
  • $height This is numeric in pixels, if you use 0 height will be proportional to height. See: http://www.binarymoon.co.uk/demo/timthumb-basic/
  • $crop Use: 0 Resize to Fit specified dimensions (no cropping), 1 Crop and resize to best fit the dimensions (default), 2 Resize proportionally to fit entire image into specified dimensions, and add borders if required, 3 Resize proportionally adjusting size of scaled image so there are no borders gaps, see: http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
  • $align c : position in the center (this is the default), t : align top, tr : align top right, tl : align top left, b : align bottom, br : align bottom right, bl : align bottom left, l : align left, r : align rightSee: http://www.binarymoon.co.uk/2010/08/timthumb-part-4-moving-crop-location/
  • $quality 70 : Image quality from the original uploaded image in percentage

NOTE: If you just define one height or width as zero (0) the other one will conserve image proportion, if is not defined it will be default value.

TODO:

  • Get the attachment metadata to make the longdesc=”” and alt=”” IMG properties.
  • Use the parameters as array to implement more options

Download & install the zip archive

The plugin package installer can be downloaded from the WP2E project tab called “code”.

1 – Select the version to download if this option is available otherwise the “latest” version of the main plugin will be used.

2 – After downloading the zip archive install the plugin package installer in you local environment and activate the script from the plugin list.

3 – Under the section “Plugins” of the admin dashboard you should see a new “Dependencies & Licenses” link. Follow the instructions from this panel to finalize the installation of the missing dependencies.

Tips: Use the WP2E panel to add/suggest new dependencies to the local installation. Press F5 in the list of dependencies if the changes are not displayed right away.

Klan1 Common WP Functions

typePlugin
version0.5
descriptionBasic functions needed by our others plugins and templates.