Add a featured image in my theme?

You need to add theme support in the functions.php file of your active theme like this: if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ); } To enable it within a custom post type, you will need to do so when registering your post type with the supports argument, so you’ll need to add … Read more

Link Featured Thumb to Attachment Page, If Possible

Question 1: How do you link Featured Image to its Attachment Page In the loop: <?php if( has_post_thumbnail() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/52394/<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>”> <?php the_post_thumbnail(); ?> </a> <?php endif; ?> Question 2: Post Format Templating Post formats are actually just a custom taxonomy with a fancy UI. Hence, you should … Read more

including image assets in widget

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

Getting custom size image URL

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]; ?>

Uploading images: ‘ø’ get replaced with ‘ø’

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.

resize only height using wp_get_image_editor

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 );

WordPress Child Theme Calling Images

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