• Resolved anefarious1

    (@anefarious1)


    I know WordPress doesn’t even work like this but… is there a way to make an uploaded image appear automatically and be viewable (immediately after upload) IF the user is redirected to another URL? If so, how? Thank you!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter anefarious1

    (@anefarious1)

    I found the other recent thread regarding a similar question. That works (editing the theme’s function.php file) but if you reload the page… the image disappears. That’s okay. At least the user sees what they uploaded and they likely won’t reload.

    Plugin Author nickboss

    (@nickboss)

    Hi, regarding your first post, it can be done with the following hook:

    if (!function_exists('wfu_after_upload_handler')) {
    	function wfu_after_upload_handler($changable_data, $additional_data) {
    		$link = "https://staging.iptanus.com/test-4-2/?wfuuid=".$additional_data["unique_id"]."&wfufid=";
    		$fid = "";
    		foreach ( $additional_data["files"] as $ind => $file ) {
    			if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" ) {
    				$fid = $ind;
    				break;
    			}
    		}
    		if ( $fid !== "" ) $changable_data["js_script"] = 'window.location.href = "'.$link.$fid.'"';
    		return $changable_data;
    	}
    	add_filter('wfu_after_upload', 'wfu_after_upload_handler', 10, 2);
    }
    if (!function_exists('wfu_show_uploaded_image_handler')) {
    	function wfu_show_uploaded_image_handler($incomingfrompost) {
    		$output = "";
    		if ( isset($_GET["wfuuid"]) && isset($_GET["wfufid"]) && WFU_USVAR_exists("filedata_".$_GET["wfuuid"]) ) {
    			$files = WFU_USVAR("filedata_".$_GET["wfuuid"]);
    			if ( isset($files[$_GET["wfufid"]]) && file_exists($files[$_GET["wfufid"]]["filepath"]) ) {
    				$url = str_replace(ABSPATH, site_url().'/', $files[$_GET["wfufid"]]["filepath"]);
    				$output .= '<div>';
    				$output .= '<img src="'.$url.'" />';
    				$output .= '</div>';
    			}
    		}
    		return $output;
    	}
    	add_shortcode("wfu_show_uploaded_image", "wfu_show_uploaded_image_handler");
    }

    You need to replace “https://staging.iptanus.com/test-4-2&#8221; in $link with the redirect URL in your case.

    You need also to put the shortcode [wfu_show_uploaded_image] in the destination page. This shortcode will be replaced by the image.

    Regards

    Nickolas

    Thread Starter anefarious1

    (@anefarious1)

    That works. Thank you sir

    Plugin Author nickboss

    (@nickboss)

    Ok good, you are welcome

    Nickolas

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Make uploaded image appear instantly’ is closed to new replies.