Image size filtering in Media uploader according to custom post type

Add following code in your themes functions.php file function theme_set_default_image_size() { global $post_type; $custom_image_size=”medium”; if($post_type == ‘news’) $custom_image_size=”news_image_size”; else if($post_type == ‘product’) $custom_image_size=”product_image_size”; else if($post_type == ‘service’) $custom_image_size=”service_image_size”; return $custom_image_size; } add_filter( ‘pre_option_image_default_size’, ‘theme_set_default_image_size’ );

Link to File URL by default

Answered a similar question on the .org forums very recently. To sum it up though.. Go to http://example.com/wp-admin/options.php (replace example.com with your website address) Scroll down the page until you see image_default_link_type Set that option to either file, post or to an empty value. Empty = No link File = Links to the file(what you … Read more

Displaying a featured image (only img url) as the img src?

Here are the functions you need to be aware of: http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id http://codex.wordpress.org/Function_Reference/wp_get_attachment_url http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src http://codex.wordpress.org/Function_Reference/wp_get_attachment_image Example sans size: echo wp_get_attachment_url(get_post_thumbnail_id()); Example with size: $image = wp_get_attachment_image_src(get_post_thumbnail_id(), ‘large’); echo $image[0]; //as HREF in your A tag You can grab all of the gallery images as follows: $args = array( ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, … Read more

Broken image multisite

After reading several topics about this issue I’ve found this: Issues with old WPMU installs If you installed WordPress MU in subfolder/subdirectory (not in root folder on your server >via ftp) and you have problem with image library, where thumbnails and images do not show, >you may need to manually add in rewrite rules for … Read more

Can’t Display Featured Image in RSS Feed

By default, RSS won’t display. You have to use RSS2. However this will help you. Paste it in your functions.php: function insert_thumbnail_into_feed() { global $post; if ( has_post_thumbnail( $post->ID ) ){ // replace thumbnail with yours $content=”<p>” .get_the_post_thumbnail( $post->ID, ‘thumbnail’ ) .'</p>’; } // get post content and replace feed content with // you can … Read more

how to base64 encode images in wordpress template

in your file functions.php in your template put this funcitons /** * @param $path * @return string * @author https://github.com/ozzpy */ function imageEncode($path) { $path = __DIR__.”https://wordpress.stackexchange.com/”.$path; $image = file_get_contents($path); $finfo = new finfo(FILEINFO_MIME_TYPE); $type = $finfo->buffer($image); return “data:”.$type.”;charset=utf-8;base64,”.base64_encode($image); } /** * @param $path * @return string * @author https://github.com/ozzpy */ function imageEncodePath($path) { $image … Read more