Disallow img tag in comments?

You can strip images on display pretty easily. add_filter( ‘comment_text’, function($comment) { $allowed_html = array( ‘a’ => array( ‘href’ => array(), ‘title’ => array() ), ‘br’ => array(), ’em’ => array(), ‘strong’ => array() ); return wp_kses($comment, $allowed_html); } ); That will strip any tags not listed in the provided array. To specifically strip images … Read more

If Media Type .GIF

I’m not quite sure you’re using the wp_check_filetype() correctly. I just successfully tried the following to determine if the post thumbnail ext was jpg or not: $url = wp_get_attachment_url( get_post_thumbnail_id( ) ); $filetype = wp_check_filetype($url); if ($filetype[ext] == ‘jpg’) { echo ‘this is gif’; } else { echo ‘this aint gif’; } You probably know … Read more

Removing height and width from images with a caption

Here is another possibility, it alters the image markup when you select an image to add to your content in the editor add_filter( ‘image_send_to_editor’, ‘remove_img_attribute’, 10, 8 ); function remove_img_attribute( $html, $id, $caption, $title, $align, $url, $size, $alt ) { $imagetpl=”<figure> <a href=”https://wordpress.stackexchange.com/questions/129666/%s” title=”https://wordpress.stackexchange.com/questions/129666/%s”><img src=”https://wordpress.stackexchange.com/questions/129666/%s” alt=”https://wordpress.stackexchange.com/questions/129666/%s” class=”img-responsive %s” /></a> %s </figure>”; $figcaption = (!empty($caption)) ? … Read more

Add an attribute to attachments

This can be done with two filters, attachment_fields_to_edit and attachment_fields_to_save, which do exactly what their names suggest. Let’s say you wan to add a source field. First, generate the field and fill it with its current value if that exists: function wpse133608_add_attachment_location_field( $form_fields, $post ) { $field_value = get_post_meta( $post->ID, ‘source’, true ); $form_fields[‘source’] = … Read more

Site migration – some images not displaying in Media Library

I highly recommend updating all of your URLS. This can be done either with a word press plugin such as Velet Blues Update URLS Or via your SQL database: UPDATE wp_posts set post_content=REPLACE(post_content, ‘www.live.com/’, ‘www.test.com/’); note* images are uploadeded as posts in your database.* ( wp_posts table with a post_type of “attachment”. )

How to remove p tags around img and iframe tags in the acf wysiwyg field

Ok if you want to strip the p tags for img’s and iframe’s for advanced custom fields you have to exchange the_content with acf_the_content . The code looks that way: 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’);

Can’t seem to attach uploaded image to post and set it as thumbnail

You have a variable scope problem. $post_id = wp_insert_post($post_information); function upload_user_file( $file = array() ) { require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $file_return = wp_handle_upload( $file, array(‘test_form’ => false ) ); // … You set $post_id outside of your upload_user_file() function but that means that it is unavailable inside the function where you need it for … Read more

Multiple images with Media Uploader on front-end

You can’t have two buttons with the same ID (#upload_image_button) as IDs are supposed to be unique. You should give the buttons a class and give the ID equal to that of the name of the associated input. <input type=”text” size=”36″ name=”image_1″ value=”http://” /> <input id=”image_1″ class=”button upload_image_button” type=”button” value=”Upload Image” /> <input type=”text” size=”36″ … Read more

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