Always use for post images

You can try the image_send_to_editor filter: /** * Wrap the inserted image html with <figure> * if the theme supports html5 and the current image has no caption: */ add_filter( ‘image_send_to_editor’, function( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if( current_theme_supports( ‘html5’ ) && ! $caption ) $html = sprintf( ‘<figure>%s</figure>’, $html … Read more

Count the number of images uploded on the website

There’s a handy built-in function, namely wp_count_attachments(). We can filter out images with wp_count_attachments( $mime_type=”image” ) that returns an object like: stdClass Object ( [image/gif] => 9 [image/jpeg] => 121 [image/png] => 20 [image/x-icon] => 6 [trash] => 0 ) So we can use the one-liner: $count = array_sum( (array) wp_count_attachments( $mime_type=”image” ) ); for … Read more

show author image in posts

I know this is old, but I just came across it shortly before I came across the solution. To display the author image inside the loop, just use this code: <?php echo get_avatar( get_the_author_meta( ‘ID’ ) , 32 ); ?> Where ’32’ is the size of the image. If it’s outside the loop, then just … Read more

Prevent large image uploads

You have a few different solutions available here: Automatically scaling down If you just do not want to store huge amounts of image data on your webspace, I’d recommend the Plugin Imsanity. This automatically scales down the uploaded images, even if they are too big. Forbid large uploads In this case the user has more … Read more

Remove P tags from images

1) Filter wpautop() with ACF: function filter_ptags_on_images($content) { $content = preg_replace(‘/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU’, ‘\1\2\3’, $content); return preg_replace(‘/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU’, ‘\1’, $content); } add_filter(‘acf_the_content’, ‘filter_ptags_on_images’); add_filter(‘the_content’, ‘filter_ptags_on_images’); If you have both of those try checking with a later priority on the add_filter. It’s possible the theme or plugin or acf is overriding you…. add_filter(‘acf_the_content’, ‘filter_ptags_on_images’, 9999); … Read more

How to upload image with simple form?

There are several parts. You need to add an enctype to the profile form. function edit_form_type_wpse_98375() { echo ‘ enctype=”multipart/form-data”‘; } add_action(‘user_edit_form_tag’,’edit_form_type_wpse_98375′); Then add a field to the form. function user_fields_wpse_98375($profileuser) { $_profile_photo = get_user_meta($profileuser->data->ID,’_profile_photo’,true); echo ‘<h3>’.__(‘Additional User Data’,THEME_TEXTDOMAIN).'</h3>’; echo ‘<tr class=”show-admin-bar”>’; echo ‘<th scope=”row”>’.__(‘Profile Photo’, THEME_TEXTDOMAIN).'</th>’; echo ‘<td’.$tspan.’>’; echo ‘<fieldset>’; echo ‘<legend class=”screen-reader-text”><span>’.__(‘Profile Photo’, … Read more

Img Src File path issue

No your file path setup is correct, you need to provide the absolute path in you img src for images to load on other pages as relative path would change to, http://yourwebsite.com/page/wp-content/themes/blankslate/images/morebutton.png and instead it should be http://yourwebsite.com/wp-content/themes/blankslate/images/morebutton.png So you should define a constant in your function.php for path to image directory, and then use … Read more