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.

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

Rename image during upload using date and time stamp?

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

New image size option not showing

You need to register the image size first using add_image_size(), for example: add_action( ‘after_setup_theme’, ‘cyb_add_image_sizes’ ); function cyb_add_image_sizes() { add_image_size( ‘my-image-size-name’, 120, 120, true ); } Then, you can use the image_size_names_choose filter (you have misspelled it with image_size_names_chooser): add_filter( ‘image_size_names_choose’, ‘rudr_new_image_sizes’ ); function rudr_new_image_sizes( $sizes ) { $addsizes = array( “my-image-size-name” => ‘Misha size’ … Read more

Responsive Images – Add srcset attributes to custom Images Function

I think wp_get_attachment_srcset() is what you are looking for. $srcset = wp_get_attachment_image_srcset( $image[‘id’], array( 100, 100 ) ); Now you can escape the HTML and use it in your code. <img src=”https://wordpress.stackexchange.com/questions/276972/PATH HERE” srcset=”https://wordpress.stackexchange.com/<?php echo esc_attr( $srcset ); ?>”>

Sidebar slideshow widget [closed]

If your just going to be showing images jQuery Cycle is the way to go. It is very light and you simply call the js in your theme then wrap your images in a div ie: <div class=”pics”> <img src=”https://wordpress.stackexchange.com/questions/1807/images/beach1.jpg” width=”200″ height=”200″ /> <img src=”images/beach2.jpg” width=”200″ height=”200″ /> <img src=”images/beach3.jpg” width=”200″ height=”200″ /> </div> Then … Read more

extract post image to be featured images

if the image is inserted (attached) into the post and not a external link: function get_my_thumbnail($post_id, $size, $attr=””){ // check of featured image first $t = get_post_thumbnail_id($post_id); // no featured image set, check post attachments if(empty($t)){ $attachments = get_children(array( ‘post_parent’ => $post_id, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘order’ => ‘ASC’, ‘orderby’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)