How do i reference the theme path in pages for images?

Use get_template_directory_uri() print get_template_directory_uri() . ‘/image.jpg’; In child themes use get_stylesheet_directory_uri() if you have replaced the image. In a shortcode this would look like this: <?php /* Plugin Name: Theme URI Shortcode */ add_shortcode(‘theme_uri’, ‘wpse_66026_theme_uri_shortcode’ ); function wpse_66026_theme_uri_shortcode( $attrs = array (), $content=”” ) { $theme_uri = is_child_theme() ? get_stylesheet_directory_uri() : get_template_directory_uri(); return trailingslashit( $theme_uri … Read more

How can I autopopulate titles in the media library?

If you can do SQL manually then try: UPDATE wp_posts p INNER JOIN wp_posts q ON p.post_type=”attachment” AND p.post_mime_type LIKE ‘image/%’ AND (p.post_title IS NULL OR LENGTH(p.post_title) = 0) AND p.post_parent = q.ID SET p.post_title = q.post_title; If you need a PHP function then try: function set_image_without_title_to_post_title() { global $wpdb; $sql = sprintf( “UPDATE %s … Read more

Add_image_size not cropping

From this comment: Sry, i forgot it, but i want size of 645×445, exactly, and that image dont have it. The width of it is 588px. Look: img201.imageshack.us/img201/4728/40405258.png WordPress need make a zoom on it. WordPress does not zoom. It only crops. If you want an image to have a custom intermediate size, then you … Read more

Custom image size not regenerating when image editted

To regenerate custom image size when image is edited in image editor , You have to add following options in wp_options table using update_option function along with add_image_size. Example : $img_size_name=”custom-size”; // The new image size name. if ( function_exists( ‘add_theme_support’ ) ) add_image_size($img_size_name, 100, 100 , true); update_option($img_size_name.’_size_w’, 100); update_option($img_size_name.’_size_h’, 100); update_option($img_size_name.’_crop’, 1);

Additional image sizes are not being generated

From https://make.wordpress.org/core/2012/12/06/wp_image_editor-is-incoming/ : Imagick support requires Imagick 2.2.0+ compiled against Imagemagick 6.2.9+, for full support. If the required functions aren’t available, WordPress will default back to GD. If you can, create a PHP file somewhere on your server with this content: <?php phpinfo(); ?>. Then load the page and see if there is a section … Read more

Strip Image Classes from HTML Output

Take a closer look at get_image_tag() which can take a lot of parameters like $id, $alt, $title, $align, $size. If you look even closer you’ll find the get_image_tag_class filter to change the image class names (like class, ID, align and size). You can use the filter within your functions.php like this: Note: This will still … Read more

Regenerate thumbnails after upload

Adding $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); after $attach_id = wp_insert_attachment( $attachment, $filename); Fixed it.