Add select field to media uploader that adds a class to the image

To apply the class you need a custom function to do something with the value of your setting. To make sure the selected stays selected use the WP selected() function $form_fields[‘image-type’][‘html’] = “<select name=”attachments[{$post->ID}][profile_image_select]”>”; $form_fields[‘image-type’][‘html’] .= ‘<option ‘.selected(get_post_meta($post->ID, “_profile_image_select”, true), ‘default’,false).’ value=”‘ . $normal_image . ‘”>Normal Image</option>’; $form_fields[‘image-type’][‘html’] .= ‘<option ‘.selected(get_post_meta($post->ID, “_profile_image_select”, true), ‘default’,false).’ value=”‘ … Read more

upload files dynamically to user folders

You can grab a WP_User instance with get_user_by() – Codex documents that pretty well. add_filter( ‘upload_dir’, ‘userLoginUploadDir’ ); function userLoginUploadDir( $args ) { // Assuming that your forms user login (search? autocomplete? AJAX-ified? foo?) is named // name=”user_login” id=”user_login” $userLogin = esc_attr( $_GET[‘user_login’] ); $user = get_user_by( ‘login’, $userLogin ); $upload_dir = wp_upload_dir(); return array_merge( … Read more

How to side load an image from a service

Short answer, you don’t. Functions like sideload are for importing images into WordPress itself and using all the normal media library stuff. For images on an external service, use normal img tags. If you want to copy an image from a URL, you sideload it. Not otherwise.

post_parent is 0 when uploading new files

The reason was the post_id key simply missing from the upload query. It was there for the normal posts, but was being omitted in the custom-post-type uploads. No idea why. The issue had something to do with the javascript uploader settings. So I’ve asked another question regarding the pluploader here and have managed to find … Read more

Modify Maximum upload file size text

This text is coming from wp-admin/includes/media.php#L1946 There is not filter is available to modify the text. But still if you wish you can use gettext filter to modify the text. add_action(‘post-html-upload-ui’, function () { add_filter(‘gettext’, ‘media_upload_limit_custom_text’); }); /** * Customize the max media size text * @param string $text * @return string $text */ function … Read more

How to set a Minimum Image Dimension for Uploading

The $file array doesn’t have anything that you’d be able to use, but $GLOBALS has some helpful information. You can uncomment the debugging line that contains $GLOBALS to see what it contains. I have added a guard clause to the top of the tc_handle_upload_prefilter function. This ensures that the file size checking code is only … Read more

What error logs can I check to see why plugin updates are failing?

In wp-config.php, set the following (if not already set): define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false ); @ini_set( ‘display_errors’, 0 ); This will make sure that on the site no error is shown, however, WordPress will log all errors in debug.log file inside the /wp-content/ directory. NOTE: You must insert this … Read more

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