Prevent WordPress from cropping GIF files

Unsetting sizes can normally be done easily via intermediate_image_sizes_advanced hook. The only problem is, there is only the $sizes array available, so this sufficient for a general level, but not if you want to do this conditionally. The information needed to do it conditionally can be gathered with debug_backtrace – debug_backtrace is performance-wise somewhat expensive … Read more

wp_get_attachment_image_src() and custom sizes

You are misreading the Codex. wp_get_attachment_image_src() works just fine with custom image sizes. Proof of concept: // copied from the Codex // https://codex.wordpress.org/Function_Reference/add_image_size if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘category-thumb’, 300, 9999 ); //300 pixels wide (and unlimited height) add_image_size( ‘homepage-thumb’, 220, 180, true ); //(cropped) } Add an image to the Library, … Read more

oEmbed, thumbnails and wordpress

Use the oembed_dataparse filter to modify the resulting HTML output by any given oembed call. Example: add_filter(‘oembed_dataparse’,’test’,10,3); function test($return, $data, $url) { if ($data->provider_name == ‘YouTube’) { return “<img src=”https://wordpress.stackexchange.com/questions/19500/{$data->thumbnail_url}”>”; } else return $return; } Then putting this in a post: Will give you a picture of Rick Astley instead of a flash video of … Read more

Featured Image of Video from oembed

I needed just this for a recent project, so here’s my plugin! The code should be self-explanatory, but if there are any questions ask away. <?php /** * Plugin Name: oEmbed Featured Image * Plugin URI: http://wordpress.stackexchange.com/q/70752/1685 * Description: Automatically set the featured image if an oEmbed-compatible embed is found in the post content. * … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)