Hi, the following script uses a plugin hook to show the uploaded image right below the upload form. You need to put it at the end of functions.php file of your theme
if (!function_exists('wfu_after_upload_handler')) {
function wfu_after_upload_handler($changable_data, $additional_data) {
foreach ( $additional_data["files"] as $file ) {
if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" ) {
$url = str_replace(ABSPATH, site_url().'/', $file["filepath"]);
$changable_data["js_script"] = "
var block = document.getElementById('wordpress_file_upload_block_1');
var div = document.getElementById('wfu_img_container');
if (div) div.parentNode.removeChild(div);
div = document.createElement('DIV');
div.id = 'wfu_img_container';
var img = document.createElement('IMG');
img.src = '$url';
div.appendChild(img);
block.parentNode.insertBefore(div, block.nextElementSibling);
";
break;
}
}
return $changable_data;
}
add_filter('wfu_after_upload', 'wfu_after_upload_handler', 10, 2);
}
Showing it in another page requires more customization, but it could be done.
Regards
Nickolas
This worked just fine. Much appreciated!
Can I ask…
Normally… you’d have to manually go in and attach an uploaded image to a post or page? There is no settings option that takes care of this?
I ask because I tried the setting, “Attach Uploaded Files To Post” but it doesn’t work. Thanks
Hi, in the language of WordPress, attaching an image to a post means that it is linked with the post (you can have many images attached to the same post). So then, an image gallery plugin can find these images and display them in the post.
For instance, if you put the shortcode [gallery] under the upload plugin, it will display the images attached to the post.
Regards
Nickolas