Add CSS class to every image
function add_image_class($class){ $class .= ‘ additional-class’; return $class; } add_filter(‘get_image_tag_class’,’add_image_class’);
function add_image_class($class){ $class .= ‘ additional-class’; return $class; } add_filter(‘get_image_tag_class’,’add_image_class’);
You cannot check the image before uploading, as WordPress is a serverside script. However, before inserting the image in the Media library, you have different options, as I explained in this answer, with filtering wp_handle_upload_prefilter. In your case, the function filtering the wp_handle_upload_prefilter would be something like this: add_filter(‘wp_handle_upload_prefilter’, ‘f711_image_size_prevent’); function f711_image_size_prevent($file) { // get … Read more
Try this: $caption_info = array(); add_filter( ‘img_caption_shortcode’, ‘capture_caption’, 10, 3 ); function capture_caption( $blank = ”, $attr, $content ) { global $caption_info; $caption_info[] = array(‘attr’ => $attr, ‘content’ => $content ); return ‘ ‘; } It will save info from all captions into global $caption_info variable and suppress their display in content (space is returned … Read more
You need to either read more about database optimization or hire a specialist and distribute those posts possibly on multiple database and file servers. Even if you build a custom solution it would be slow so don’t blame WP.
Try adding this to functions.php: add_filter(“wp_image_editors”, “my_wp_image_editors”); function my_wp_image_editors($editors) { array_unshift($editors, “WP_Image_Editor_Custom”); return $editors; } // Include the existing classes first in order to extend them. require_once ABSPATH . WPINC . “/class-wp-image-editor.php”; require_once ABSPATH . WPINC . “/class-wp-image-editor-gd.php”; class WP_Image_Editor_Custom extends WP_Image_Editor_GD { public function generate_filename($suffix = null, $dest_path = null, $extension = null) { … Read more
If the question is “Why don’t my images load?” the answer is “Don’t use relative URLs in a WordPress context.” Use functions like admin_url and these other related functions instead. Relative URLs are relative to the URL of the page you are on, and are calculated by the browser. In other words, relative URLs are … Read more
Sent Header The following error simply states that the error message was output directly (sent header) Warning: Cannot modify header information – headers already sent by (output started at /home/lorem/public_html/clients/ipsum/wp-content/plugins/myplugin/test.php:504) in /home/lorem/public_html/clients/ipsum/wp-includes/pluggable.php on line 864 PHP Error notice Notice: Undefined variable: post_id in /home/lorem/public_html/clients/ipsum/wp-content/plugins/myplugin/test.php on line 18 $_REQUEST is a combination of a lot of … Read more
(Update 04.05.2012: Include captions) Let’s start with a solution … There is no filter especially for gallery image links. There is also no filter for the gallery shortcode output. So we have to fake one: add_action( ‘after_setup_theme’, ‘wpse_50911_replace_img_shortcodes’ ); /** * Replace the default shortcode handlers. * * @return void */ function wpse_50911_replace_img_shortcodes() { remove_shortcode( … Read more
I won’t go into the code specifics right now, because I am not sure if you need me to. You essentially need to modify the SWFUpload JavaScript settings array to set the file_upload_limit to 1. Unfortunately I don’t believe SWFUpload allows you to change that settings variable after it has been inited, because it has … Read more
Instead of pasting into the Visual editor, switch to the html editor for pasting any kind of html, or using shortcodes. I’d recommend checking the “disable the visual editor” checkbox in your user profile. Then install Mark Jaquith’s Markdown on Save plugin for more readable formatting without the wysiwyg pitfalls.