Youtube dimensions wordpress - wordpress

Is it possible to change the default embed dimensions of an youtube (or another video) in Wordpress for your current theme? I've searched for a plugin and some code, but I can't seem to find any.
What I mean is the default embed size used when you just paste an youtube url in an post or page.

Open your theme’s functions.php file, and add the following code:
if ( ! isset( $content_width ) ) $content_width = 600;
Remember to change the number 600 appropriately for your theme. It is the maximum width in pixels for your content area.
Once you do this, WordPress will automatically use that for the maximum width of your oEmbed elements (youtube videos, slideshare, etc).
via wpbeginner.com

The media settings have been removed. You can do it with a filter however.
function mycustom_embed_defaults($embed_size){
$embed_size['width'] = 600; // Adjust values to your needs
$embed_size['height'] = 500;
return $embed_size; // Return new size
}
add_filter('embed_defaults', 'mycustom_embed_defaults');
Taken from here http://shailan.com/2154/change-wordpress-default-embed-size-using-filters/

The currently accepted answer has an example that uses the following shortcode:
[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]
The shortcode [youtube] only works if you have the Jetpack plugin installed.
To make it work with WordPress with no Jetpack you can use the built-in [embed] shortcode like this:
[embed width=640 height=385]http://www.youtube.com/watch?v=0Bmhjf0rKe8[/embed]

To change the default embed size go to Settings > Media and just set a fixed width/height.
You also have the shortcode
[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]
where you can manually insert width and height as params. This shortcode will overwrite the default WP settings.

They've got rid of the fixed width/height option in the media settings of the new version of Wordpress. Not sure why. It was useful!! Shortcodes don't seem to work either.

Related

How to prevent from woocommerce css over rides template css file?

As you see in following pictureenter image description here.
woocomerce css styles has magically over ride my template css (after using yith tab manager permiume (disabling doesn't help).
You can see that disable those styles from woocomerce.css will prove that, y template style is still there.
How can I prevent from this issue ?
Here is the website link for that page
amatistrading.
I used this code in functions.php of template but it didn't work:
:// Disable WooCommerce's Default Stylesheets
function disable_woocommerce_default_css( $styles ) {
// Disable the stylesheets below via unset():
unset( $styles['woocommerce-general'] ); // Styling of buttons, dropdowns, etc.
// unset( $styles['woocommerce-layout'] ); // Layout for columns, positioning.
// unset( $styles['woocommerce-smallscreen'] ); // Responsive design for mobile devices.
return $styles;
}
add_action('woocommerce_enqueue_styles', 'disable_woocommerce_default_css');
i couldnt use that code(in main comment) but i found a way to solve problem. ( i will put the right code if i find any),first we can delete that stylesheet content, or act like me: disable all plugins(every single plugin) try to replace woocommerce files with orginal, then re active plugins, this method worked for me, it seems changing woocommerce files made this problem.

Wordpress select and crop in plugin

I needs to upload images in my plugin and use wp.media for this task.
According to https://codex.wordpress.org/Javascript_Reference/wp.media
Its work, but I needs to have "Select and Crop" option in media library after upload my image with custom size.
I was see this in default theme in appearence custom header image, but can't understand how I can use this in my plugin with wp.media js?
This my not be better solution but work in wordpress :)
i use Thumbnail Crop Position and Simple Image Sizes for that :)
Good luck! :)
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('yourImageSize');
}?>
See my answer posted here that does Select and Crop using the Media Library on a theme options page. You can use it as a starting point for getting it to work in a plugin:
https://wordpress.stackexchange.com/questions/281760/using-media-uploader-to-select-image-of-specific-size-enforce-cropper/302962#302962

Wordpress image resize quality could be better

I do use the automatic resize function of wordpress and have already set the image quality for jpgs to a much higher quality via the functions.php file like so:
add_filter('jpeg_quality', function($arg)
{
return 90;
}
);
However, the resulting image quality is still not very good. The pictures could need a sharpening pass or a different resize algorithm.
I did not find any way to tell wordpress to use a different algorithm so far - does anyone know a hook or something similar to increase the quality?
All you need to do is paste the following code in your theme’s functions.php file or your site-specific plugin.
function gpp_jpeg_quality_callback($arg)
{
return (int)100;
}
add_filter('jpeg_quality', 'gpp_jpeg_quality_callback');
Or
add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );
You can change from admin panel .
Setting >> media >> here you can add you size for images.
for thumbnail,small ,large images .

Wordpress - How to change thumbnail size on Homepage? Can't find reference

I've searched throughout and can't find where to change the base thumbnail size on the Homepage (www.tomcpalead.com). It's set to 210 x 158. I change the Functions.php and nothing updates on the Homepage. Can't find the reference in style.css to edit it either.
Can someone help?
Thanks
The size of your thumbnails seems to be coming from here:
http://tomcpalead.com/?custom-css=1&csblog=1&cscache=6&csrev=4
I haven't seen CSS files named like that before though, so I'll defer to others who will have a better idea of where that's coming from. If there's any setting somewhere in your theme that looks like the following then that is what I would try editing:
.river .thumb img{width:16rem;height:9.75rem}
Just go to wordpress admin and follow this path :
Go to admin => Settings => Media
here, you will get the thumbnail size for all the images defined. You can change it as per your choice.
After modifying size, just check it by uploading a new image and set it a thumbnail image.

Setting thumbnail featured image size not working properly

Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails' , array('post'));
set_post_thumbnail_size(200,120);
}
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
It seems that my featured images are not always set to the same size.For example if the image is smaller then what size I set it will remain the same , for big images the width is the same but for some the height is different.
What am I doing wrong here?
Are you setting the thumbnail size in functions.php? It will not work properly if it's just in index.php or another theme file.
From the codex:
This feature must be called before the init hook is fired. That means
it needs to be placed directly into functions.php or within a function
attached to the 'after_setup_theme' hook. For custom post types, you
can also add post thumbnails using the register_post_type function as
well.
the_post_thumbnail() displays the thumbnail and should be placed where you want the thumbnail to display.

Resources