create html with variable as image source

Hi,

I have an automator application that essentially does the following:

  1. Uses my source image
  2. Makes source image name Web friendly
  3. Uploads Image to FTP
  4. Copies uploaded Image path to clipboard (using baseurl so it becomes http://mybaseurl.com/image-name.png)

What I would like to accomplish is to have a step where I create html code and insert the source image as part of that html.

More or less:

Anyone have an idea how I could accomplish that?

Thanks

Where are you wanting the html code to end up?

Hi,

Preferably in a file in a temp folder and I will then use ftp upload automator action to get image and file on server.

I actually found a good basis on the site here that I have bastardized to partly do what I want, however, I don’t know how I can get my automator image / variable into the equation.

That would be the part in the script where & html_array & needs to become my image.

FYI, I am creating this in automator, where this part below is set with “Run Apple Script”

on run {input, parameters}
	
	tell application "Finder"
		beep
		--location for the TODO.html file:
		set buildFolder to "Macintosh HD:Users:username:Desktop:todo-list:html_holder:" as alias
		delete every item in buildFolder
		set buildFile to make new file at buildFolder with properties {name:"TODO.html"}
		set buildFile to buildFile as text
		--default pic:
		set my_pic to "../background_pic.jpg"
		--silly video/webpage to visit to celebrate finishing your TODO list!
		set my_celebration to "https://www.youtube.com/watch?v=MW1gHwiZJFg"
		
		(* Obviously edit my_pic to point to the relative path to your background pic and build folder to where you'll store the TODO list html file.  Entering it manually saves from having to annoyingly change the pic each time the script runs.  
*)
		
		
		
		--Now that we have the TODO list written in HTML, we'll store the rest of the HTML/CSS code in a variable.  Edit the HTML/CSS code to your preference I guess.
		
		set html_page to "<!Doctype html>
<html>
<head>
<title>Daily TODO List</title>
<style>

table {
font-size: 20px;
font-family: Comic Sans MS;
	position: fixed;
	top: 20%;
	left: 15%;
	color: white;
	 -webkit-border-radius: 10px;
	border-radius: 10px; 
	padding-left: 1%;
	padding-right: 1%;
	}
	
	td {
	padding-left: 15px;
	}
a {
color: rgba(255,255,255,1);
text-decoration: none;
background-color: rgba(219,87,5,1);
font-family: 'Yanone Kaffeesatz';
font-weight: 700;
display: block;
padding: 4px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
-moz-box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
width: 160px;
text-align: center;
-webkit-transition: all .1s ease 0s;
-moz-transition: all .1s ease 0s;
-ms-transition: all .1s ease 0s;
-o-transition: all .1s ease 0s;
transition: all .1s ease 0s;
}

a:active {
-webkit-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
-moz-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
position: relative;
top: 6px;
}
	section {
	column-count: 1;
	}

	body {
	background: url(" & my_pic & ") no-repeat center center fixed;
	-webkit-background-size: cover;
  	-moz-background-size: cover;
  	-o-background-size: cover;
  	background-size: cover;
	}
section {
position: absolute;
top: 80%;
left: 15%;
}

</style>
</head>
<body>
<img src='
" & html_array & "
'>
<section>
<a href='" & my_celebration & "'>I Finished!!</a>
</section>
</body>
</html>"
	end tell
	
	-------------------------------------------------------------------
	--Ok, now we've got the html file so we'll write it to an actual file here
	
	set the open_buildFile to open for access file buildFile with write permission
	write html_page to open_buildFile
	close access the open_buildFile
	
	tell application "Finder"
		beep
		display dialog "Ok, all done." & return & return & "Now stop looking at news and get to work."
	end tell
	
	return input
end run