How to scale up post thumbnails/featured image?
As WordPress thumbnail generator doesn’t do this “scale up” thing, you can do it using the following CSS rule: .featured_thumb img{ width:100%; height: 100%; } Hope it will help.
As WordPress thumbnail generator doesn’t do this “scale up” thing, you can do it using the following CSS rule: .featured_thumb img{ width:100%; height: 100%; } Hope it will help.
It sounds like you’ll need the plugins_url() function which generates the URL for the plugins directory and can handle any alternate configuration (such as if you moved it to the /mu-plugins/ directory, a personal favorite of mine). The Codex documentation is good, but here’s a quick example. Let’s say you’re making this in a plugin … Read more
You can do this with a piece of the code from the “Post Thumbnail Linking to large Image Size” example on the get_the_post_thumbnail page (using wp_get_attachment_image_src): <?php $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘team-member’ ); // actual URL = $image_url[0]; ?>
WP sanitize_file_name() function doesn’t handle those characters by default. You can add filter and sanitize those to avoid encoding issues. function mamaduka_sanitize_file_name( $filename ) { $filename = strtr($filename, ‘ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǺǻǼǽǾǿ’, ‘SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyyAAAAAAAECEEEEIIIIDNOOOOOOUUUUYsaaaaaaaeceeeeiiiinoooooouuuuyyAaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkLlLlLlLlllNnNnNnnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzsfOoUuAaIiOoUuUuUuUuUuAaAEaeOo’); return $filename; } add_filter( ‘sanitize_file_name’, ‘mamaduka_sanitize_file_name’ ); Code example for this trac comment – https://core.trac.wordpress.org/ticket/16330#comment:22.
You can get the original sizes of the image being uploaded: list( $uploaded_width, $uploaded_height ) = getimagesize( $_FILES[‘u_img’][‘tmp_name’] ); Then you can use those values to size the image as you like: $height = 300; $image = wp_get_image_editor( $_FILES[‘u_img’][‘tmp_name’] ); $image->resize( $uploaded_width, $height, true );
You could try the following if you have a child theme and trying to reference your images from that file location, onto your custom .php files… <img src=”https://wordpress.stackexchange.com/questions/226211/<?php echo get_stylesheet_directory_uri(); ?>/assets/images/your-custom-image.jpg” /> Just make sure in your child theme location, you really have a child folder structure of… assets -> images
{{ post.thumbnail.ID }} will get you the image ID, but to answer what you’re after…. <img src=”https://wordpress.stackexchange.com/questions/228726/{{ post.thumbnail.src(“medium_16x9′) | default( Image(1234).src(‘medium_16x9’) ) }}”> Reference
You could e.g. check the filename and extension from the pathinfo, after your custom sanitization. Example: If the filename is empty and extension non-empty, then add the formatted current time as the filename part: $info = pathinfo( $file[‘name’] ); if( empty( $info[‘filename’] ) && ! empty( $info[‘extension’] ) ) $file[‘name’] = sprintf( ‘%s.%s’, current_time( ‘Y-m-d-H-i-s’ … Read more
Tested and confirmed that this works: add_filter( ‘the_content’, ‘add_image_dimensions’ ); function add_image_dimensions( $content ) { preg_match_all( ‘/<img[^>]+>/i’, $content, $images); if (count($images) < 1) return $content; foreach ($images[0] as $image) { preg_match_all( ‘/(alt|title|src|width|class|id|height)=(“[^”]*”)/i’, $image, $img ); if ( !in_array( ‘src’, $img[1] ) ) continue; if ( !in_array( ‘width’, $img[1] ) || !in_array( ‘height’, $img[1] ) ) … Read more
You can use PHP strip_tags and hook to the_content filter by checking if user is logged in. add this to your functions.php file add_filter( ‘the_content’, ‘wpse_remove_img’ ); function wpse_remove_img( $content ){ if( ! is_user_logged_in() ){ // You need to specify which tag you want to keep here it’s p, a, h2,span, div. // Adjust accordingly … Read more