Wordpress Question:
In the "Header Image" section of my Wordpress dashboard, it indicates, "Images of exactly 1280 × 416 pixels will be used as-is." But when I upload an image of that size, the image is cropped at the top and bottom (I'm using the Hemingway theme). Plus, when I do an "Inspect Element" on the header image, it indicates the image is only 1214 x 243 pixels. Yet there appears to be no cropping in the x-direction. Both of these are unexpected considering the Wordpress instructions on the header page. Can someone shed some light on this?
Thanks in advance.
edit: fwiw my site is www.panyadee.ac.th/test/
Take a look in your theme's functions.php file for add_theme_support. This function registers support for the custom header image. Regarding the width and height of the default image, you can pass some $args like this:
$default_args = array(
'default-image' => '',
'random-default' => false,
'width' => 0,
'height' => 0,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => '',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $default_args );
Try making sure that height and width are set.
Ref: http://codex.wordpress.org/Function_Reference/add_theme_support
Wordpress cuts some area to provide an option to crop the uploaded image. You need to extend the bottom area from the cropping region according to your mentioned size.
Related
Wordpress admin customizer control is incomplete. How can I fix it?
My Code:
$wp_customize->add_setting('swag_header_media');
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'swag_header_media', array(
'label' => 'Current Image Selection',
'section' => 'swag_header_media_section',
'active_callback' => 'header_show_image_selection_settings_callback',
'settings' => 'swag_header_media'
)));
The results are incomplete. I can select an image from the and the image show up in the frontend of the theme. However, the image selected does not show that it is being used in the control.
In other words(see screenshot), you can see the background image being used(phone), but it doesn't show that it being used in the admin customizer control. Its says "Current Image Selection", but it's empty with no buttons below it to change or remove it.
When you inspect the page, is there any errors?
It is a bit hard to figure out with so little data.
Try this 'settings' => 'themename_theme_options[swag_header_media]',
Try:
$wp_customize->add_setting('themename_theme_mods[swag_header_media]',array(
//'default' => 'image.jpg',
//'capability' => 'edit_theme_options',
//'type' => 'option'
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'swag_header_media', array(
'label' => 'Current Image Selection',
'section' => 'swag_header_media_section',
'active_callback' => 'header_show_image_selection_settings_callback',
'settings' => 'themename_theme_mods[swag_header_media]'
)));
if that doesnt work,I suggest to change swag_header_media to other keyname. I suspect that key name might be used by other control/funtion too. So, try to add any 1 letter to that keyname, and see the result. Also, if you have any caching on site, turn it off.
also, the problem could be with callback,
using WooCommerce I put this snippet in function.php to define the size of images overwriting the panel settings :
function yourtheme_woocommerce_image_dimensions() {
$single = array(
'width' => '400', // px
'height' => '300', // px
'crop' => 1 // true
);
$thumbnail = array(
'width' => '180', // px
'height' => '135', // px
'crop' => 1 // false
);
$catalog = array(
'width' => '140', // px
'height' => '105', // px
'crop' => 1 // true
);
// Image sizes
update_option( 'shop_single_image_size', $single ); // Single product image
update_option( 'shop_thumbnail_image_size', $thumbnail );
update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
All works fine but now I'd like to set different image sizes relating to $catalog just in single product page (where there's a widget showing that images).
I've tried with conditional statements, cause I don't want to use css tricks, but without luck.
Any help will be appreciate.
Thank you.
Did you re-generate the thumbnails after changing the size? If no, than try force regenerate thumbnails plugin to re-generate images that will have new sizes. When indicating new size in Wp functions, than it will affect new uploads but you also need to regenerate new sizes for previously uploaded ones.
Setting the size for a thumbnail is not a problem, but I also want to crop the image from top and to the left, but it's not working!
Inside functions.php I have this code:
function theme_setup() {
register_nav_menus(array(
'primary' => __('Main Menu'),
'footer' => __('Footer Menu'),
));
add_theme_support('post-thumbnails');
add_image_size('thumbnail', 300, 300, true);
add_image_size('post', 800,400, true);
}
add_action('after_setup_theme', 'theme_setup');
I have tested to add this code inside the function:
add_image_size('thumbnail', 300, 300, array( 'top', 'left'));
But it's not cropping from top left. All thumbnails are cropped center center
I saw this code on the WordPress Codex page:
set_post_thumbnail_size( 300, 300, array( 'top', 'left') );
If I should use this insted, how should I add this in functions.php to get it to work? I just tested to paste it in the code, but it's not working that either!
Any ideas why my code isn't working or suggestion how to improve the code?
EDIT: I forgot to write that I also has used the plugin Regenerate Thumbnails before I have changed the settings for the thumbnails.
I created a wordpress theme based on the classic twentyten theme.
I changed the size of the header images in the functions.php but apart from that I didnt mess around with the custom header stuff. Now wordpress is ignoring it when I assign featured images to pages and instead only displays the background selected in the header settings.
The size of the image doesnt seem to have anything to do with the problem. I have tried using the exact image size and larger images, they are always ignored...
Thanks if you can help!
PS. Here a link to the website: http://stuck-mueller.de/beta/
here is the code from the functions.php:
// The custom header business starts here.
$custom_header_support = array(
// The default image to use.
// The %s is a placeholder for the theme template directory URI.
'default-image' => '%s/images/headers/path.jpg',
// The height and width of our custom header.
'width' => apply_filters( 'twentyten_header_image_width', 960 ),
'height' => apply_filters( 'twentyten_header_image_height', 240 ),
// Support flexible heights.
'flex-height' => true,
// Don't support text inside the header image.
'header-text' => false,
// Callback for styling the header preview in the admin.
'admin-head-callback' => 'twentyten_admin_header_style',
);
add_theme_support( 'custom-header', $custom_header_support );
if ( ! function_exists( 'get_custom_header' ) ) {
// This is all for compatibility with versions of WordPress prior to 3.4.
define( 'HEADER_TEXTCOLOR', '' );
define( 'NO_HEADER_TEXT', true );
define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
add_custom_background();
}
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be 940 pixels wide by 198 pixels tall.
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
You don't need the apply_filters() just assign the width and height to integers like:
'width' => 960,
'height' => 240,
Check out the codex here for more info
I want to add WP editor with TinyMCE to my custom text widget, but it won't show TinyMCE buttons it just shows textarea. When I test my code on page.php it works perfectly - editor shows with all the buttons and metabox. Can You please tell me what I'm doing wrong?EDITWidgets screenshot.Same code used in page.php screenshot
The code I use :
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'textarea_name' => 'test-editor',
'textarea_rows' => get_option('default_post_edit_rows', 10),
'tabindex' => '',
'editor_css' => '',
'editor_class' => '',
'teeny' => true,
'dfw' => true,
'tinymce' => array(
'theme_advanced_buttons1' => 'bold,italic,underline'
),
'quicktags' => false
);
wp_editor( 'Text in editor', 'test-editor', $settings );
Looks like you need to find another WYSIWYG editor. Reading the Codex, there are two issues with your code:
The $editor_id
can only be composed of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction.
And this one that prevents the editor from working in a meta box
Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.