Creating a Base64 to Image converter

How would one of these be made in jsfiddle?
@coothead

How is their code set up?

This is part of, or all of the javascript code I found:

function setBase64ToImage(){

	var baseString = $("#base64string").val().trim();
	// data:image/png;base64

	if(baseString.substring(0,4) != "data"){
		baseString = "data:image/png;base64," + baseString;
	}

	$("#base64Img").prop('src',baseString);	
	$("#base64Img").addClass("span12 baseurlopa2");
	$("#dwnldLink").show();
	$("#dwnldLink").prop('href',baseString);
}


    $(document).ready(function() {
        //called after everything loaded
        setDefaultData();
        conditionalCode();
        $("#me").click();
    });

I got this far:
What else would I need to do to get it working?

<textarea id="base64string" class="span8 preview" rows="6" placeholder="Enter Base64 String"></textarea>

<input type="button" value="Generate Image" class="btn span3 btn-large span11" title="Generate Image" onclick="setBase64ToImage()">


function setBase64ToImage(){

	var baseString = $("#base64string").val().trim();
	// data:image/png;base64

	if(baseString.substring(0,4) != "data"){
		baseString = "data:image/png;base64," + baseString;
	}

	$("#base64Img").prop('src',baseString);	
	$("#base64Img").addClass("span12 baseurlopa2");
	$("#dwnldLink").show();
	$("#dwnldLink").prop('href',baseString);
}


    $(document).ready(function() {
        //called after everything loaded
        setDefaultData();
        conditionalCode();
        $("#me").click();
    });

image

You might find the following encoder-decoder useful.
LINK TO TOOL

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.