Extending WP’s upload/insert media functionality

Both of these are possible. Insert Attachment into Media Library By using the wp_insert_attachment function, you can insert your uploaded images to the Media Library. This is the example code from the Docs: <?php $wp_filetype = wp_check_filetype(basename($filename), null ); $wp_upload_dir = wp_upload_dir(); $attachment = array( ‘guid’ => $wp_upload_dir[‘baseurl’] . _wp_relative_upload_path( $filename ), ‘post_mime_type’ => $wp_filetype[‘type’], … Read more

Disable gallery in 3.5 media iframe

You can disable tabs using a filter hook. Replace wpse_76095_isOurMediaUpload() with however you determine that you’re running the media popup. add_filter(‘media_upload_tabs’, ‘wpse_76095_filterMediaUploadTabs’); /** * filter out unwanted media upload tabs * @param array $tabs * @return array */ function wpse_76095_filterMediaUploadTabs($tabs) { if (wpse_76095_isOurMediaUpload()) { unset( $tabs[‘type_url’], // no linking from external sites (no local image) … Read more

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.

Make attachment pages require a base url

Endpoints are for adding extra query vars to existing routes, I think you just want a vanilla rewrite rule here: function wpd_media_image_rewrite_rule() { add_rewrite_rule( ‘^image/([^/]*)/?’, ‘index.php?post_type=attachment&name=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpd_media_image_rewrite_rule’ ); You might want to loop over valid mime-types there and add a rule for each. You also need to flush rewrites for … Read more

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