Using an image caption in Markdown Jekyll - github

I am hosting a Jekyll Blog on Github and write my posts with Markdown. When I am adding images, I do it the following way:
![name of the image](http://link.com/image.jpg)
This then shows the image in the text.
However, how can I tell Markdown to add a caption which is presented below or above the image?

I know this is an old question but I thought I'd still share my method of adding image captions. You won't be able to use the caption or figcaption tags, but this would be a simple alternative without using any plugins.
In your markdown, you can wrap your caption with the emphasis tag and put it directly underneath the image without inserting a new line like so:
![](path_to_image)
*image_caption*
This would generate the following HTML:
<p>
<img src="path_to_image" alt>
<em>image_caption</em>
</p>
Then in your CSS you can style it using the following selector without interfering with other em tags on the page:
img + em { }
Note that you must not have a blank line between the image and the caption because that would instead generate:
<p>
<img src="path_to_image" alt>
</p>
<p>
<em>image_caption</em>
</p>
You can also use whatever tag you want other than em. Just make sure there is a tag, otherwise you won't be able to style it.

You can use table for this. It works fine.
| ![space-1.jpg](http://www.storywarren.com/wp-content/uploads/2016/09/space-1.jpg) |
|:--:|
| *Space* |
Result:

If you don't want to use any plugins (which means you can push it to GitHub directly without generating the site first), you can create a new file named image.html in _includes:
<figure class="image">
<img src="{{ include.url }}" alt="{{ include.description }}">
<figcaption>{{ include.description }}</figcaption>
</figure>
And then display the image from your markdown with:
{% include image.html url="/images/my-cat.jpg" description="My cat, Robert Downey Jr." %}

The correct HTML to use for images with captions, is <figure> with <figcaption>.
There's no Markdown equivalent for this, so if you're only adding the occasional caption, I'd encourage you to just add that html into your Markdown document:
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
<figure>
<img src="{{site.url}}/assets/image.jpg" alt="my alt text"/>
<figcaption>This is my caption text.</figcaption>
</figure>
Vestibulum eu vulputate magna...
The Markdown spec encourages you to embed HTML in cases like this, so it will display just fine. It's also a lot simpler than messing with plugins.
If you're trying to use other Markdown-y features (like tables, asterisks, etc) to produce captions, then you're just hacking around how Markdown was intended to be used.

A slight riff on the top voted answer that I found to be a little more explicit is to use the jekyll syntax for adding a class to something and then style it that way.
So in the post you would have:
![My image](/images/my-image.png)
{:.image-caption}
*The caption for my image*
And then in your CSS file you can do something like this:
.image-caption {
text-align: center;
font-size: .8rem;
color: lightgrey;
Comes out looking good!

There are two semantically correct solutions to this question:
Using a plugin
Creating a custom include
1. Using a plugin
I've tried a couple of plugins doing this and my favourite is jekyll-figure.
1.1. Install jekyll-figure
One way to install jekyll-figure is to add gem "jekyll-figure" to your Gemfile in your plugins group.
Then run bundle install from your terminal window.
1.2. Use jekyll-figure
Simply wrap your markdown in {% figure %} and {% endfigure %} tags.
You caption goes in the opening {% figure %} tag, and you can even style it with markdown!
Example:
{% figure caption:"Le logo de **Jekyll** et son clin d'oeil à Robert Louis Stevenson" %}
![Le logo de Jekyll](/assets/images/2018-08-07-jekyll-logo.png)
{% endfigure %}
1.3. Style it
Now that your images and captions are semantically correct, you can apply CSS as you wish to:
figure (for both image and caption)
figure img (for image only)
figcaption (for caption only)
2. Creating a custom include
You'll need to create an image.html file in your _includes folder, and include it using Liquid in Markdown.
2.1. Create _includes/image.html
Create the image.html document in your _includes folder :
<!-- _includes/image.html -->
<figure>
{% if include.url %}
<a href="{{ include.url }}">
{% endif %}
<img
{% if include.srcabs %}
src="{{ include.srcabs }}"
{% else %}
src="{{ site.baseurl }}/assets/images/{{ include.src }}"
{% endif %}
alt="{{ include.alt }}">
{% if include.url %}
</a>
{% endif %}
{% if include.caption %}
<figcaption>{{ include.caption }}</figcaption>
{% endif %}
</figure>
2.2. In Markdown, include an image using Liquid
An image in /assets/images with a caption:
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="jekyll-logo.png" <!-- image filename (placed in /assets/images) -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
An (external) image using an absolute URL: (change src="" to srcabs="")
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
srcabs="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
A clickable image: (add url="" argument)
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
url="https://jekyllrb.com" <!-- destination url -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
An image without a caption:
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
alt="Jekyll's logo" <!-- alt text -->
%}
2.3. Style it
Now that your images and captions are semantically correct, you can apply CSS as you wish to:
figure (for both image and caption)
figure img (for image only)
figcaption (for caption only)

You can try to use pandoc as your converter. Here's a jekyll plugin to implement this. Pandoc will be able to add a figure caption the same as your alt attribute automatically.
But you have to push the compiled site because github doesn't allow plugins in Github pages for security.

Andrew's #andrew-wei answer works great. You can also chain a few together, depending on what you are trying to do. This, for example, gets you an image with alt, title and caption with a line break and bold and italics in different parts of the caption:
img + br + strong {margin-top: 5px; margin-bottom: 7px; font-style:italic; font-size: 12px; }
img + br + strong + em {margin-top: 5px; margin-bottom: 7px; font-size: 12px; font-style:italic;}
With the following <img> markdown:
![description](https://img.jpg "description")
***Image:*** *description*

<p align="center">
<img alt="img-name" src="/path/image-name.png" width="300">
<br>
<em>caption</em>
</p>
That is the basic caption use. Not necessary to use an extra plugin.

Here's the simplest (but not prettiest) solution: make a table around the whole thing. There are obviously scaling issues, and this is why I give my example with the HTML so that you can modify the image size easily. This worked for me.
| <img src="" alt="" style="width: 400px;"/> |
| My Caption |

For Kramdown, you can use {:refdef: style="text-align: center;"} to align center
{:refdef: style="text-align: center;"}
![example](https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg){: width="50%" .shadow}
{: refdef}
{:refdef: style="text-align: center;"}
*Fig.1: This is an example image. [Source](https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg)*
{: refdef}
You need to add {::options parse_block_html="true" /} at the beginning of the post for this to work.

This option might seem complicated on the surface, but it is not at all and solves other problems that the Jekyll markdown renderer (Kramdown) has. Basically this option changes the renderer for one made with python that is expandable, allowing you to instally extensions (there are a ton, markdown-captions for example) and expand it (it has an extension API).
The first step is to define a custom markdown processor. You will have to add markdown: CustomProcessor to the _config.yml.
Then, we have to create the CustomProcessor. Create a folder called _plugins and add a file called MyConverter.rb with this content:
class Jekyll::Converters::Markdown::CustomProcessor
def initialize(config)
end
def matches(ext)
ext =~ /^\.(md|markdown)$/i
end
def output_ext(ext)
".html"
end
def convert(content)
puts "EXECUTED"
md_path = "./_plugins/temp/temp.md"
html_path = "./_plugins/temp/temp.html"
File.write(md_path, content, mode: "w")
system("python ./_plugins/MyConverter.py")
content = File.read(html_path)
content
end
end
You will also need to create a folder temp inside plugins.
All that code does is to write all the content of the file we are processing to temp.md, call a python script, wait until it finishes, read temp.html, and return it as the output of the converter.
Now it is time to create our converter in python. I have choosen to use Python-Markdown. It is easy to use and has a ton of extensions. To use the converter we have to create a file called MyConverter.py inside the _plugins folder and put this content inside:
import markdown
markdown_extensions = [
'markdown_captions',
'def_list',
'nl2br',
'tables',
'codehilite',
'fenced_code',
'md_in_html',
'attr_list'
]
md_file = open("./_plugins/temp/temp.md", "r")
md_string = md_file.read()
md_file.close()
html_string = markdown.markdown(md_string, extensions=markdown_extensions, extension_configs =extension_configs)
html_file = open("./_plugins/temp/temp.html", "w")
html_file.write(html_string)
html_file.close()
That code just loads the extensions, reads temp.md file, converts it to html and writtes it to temp.html. Using all those extensions should generate a similar output to the default jekyll markdown rendere. The only extension that is not bundled with python-markdown is markdown_captions, the one that does the magic. To install the python renderer and the extension you just have to run pip install Markdown markdown-captions.
That should do it, now your markdown is being translated by Python-Markdown. Some html elements my be different now (in my experience just a few) so maybe you have to make small changes in the css.
This is the css that I am using with the camptions:
figure{
margin: 0px;
}
figcaption {
color: gray;
font-size: 0.8rem;
}
The process tries to be as simple as possible to make it easy to understand and modify. I have described the process as well as I could remember. If anybody has a problem just leave a comment and I will update the answer.

Add the following config in the _config.yml file
# prose.io config
prose:
rooturl: '_posts'
media: 'img'
ignore:
- 404.html
- LICENSE
- feed.xml
- _config.yml
- /_layouts
- /_includes
- /css
- /img
- /js
metadata:
_posts:
- name: "layout"
field:
element: "hidden"
value: "post"
- name: "title"
field:
element: "text"
label: "Post title"
placeholder: "Title"
alterable: true
- name: "subtitle"
field:
element: "textarea"
label: "Subtitle"
placeholder: "A description of your post."
alterable: true
- name: "date"
field:
element: "text"
label: "Date"
help: "Enter date of post."
placeholder: "yyyy-mm-dd"
alterable: true
- name: "image"
field:
element: "text"
label: "Image"
help: "Add a thumbnail image to your post."
placeholder: "Thumbnail"
alterable: true
- name: "published"
field:
element: "checkbox"
label: "Publish"
help: "Check to publish post, uncheck to hide."

You can use this javascript that automatically generates a figcaption from the image's alt.
You can add some css to make the bottom text look more realistic.
The same applies to markdown. Whatever text you put ![HERE]() appears below the image.
var images = document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
var altText = images[i].getAttribute("alt");
var figcaption = document.createElement("figcaption");
figcaption.innerHTML = altText;
images[i].insertAdjacentElement("afterend", figcaption);
}
var images = document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
var altText = images[i].getAttribute("alt");
var figcaption = document.createElement("figcaption");
figcaption.innerHTML = altText;
images[i].insertAdjacentElement("afterend", figcaption);
}
<img src="https://www.w3schools.com/tags/img_girl.jpg" alt="Girl in a jacket">

Related

What does VS Code's setting html.format.unformatted do?

I'm trying to figure out what the VS Code html.format.unformatted setting does, but I can't.
I've found this issue and this issue in GitHub, but it explains nothing.
Can someone please explain to me what the html.format.unformatted setting does and how it differs from the html.format.contentUnformatted setting?
After much trial and error i found out this:
TLDR:
html.format.unformatted: does not format the tag itself nor the content
html.format.contentUnformatted: will format the tag but not the content
source (not very clear, imho): https://code.visualstudio.com/Docs/languages/html
Sample html code (not valid, i know, but irrelevant here):
<body>
<style class="foo" class="foo" class="foo" >
.foo {
background-image: 'bar.jpeg';
background-size: cover;
background-position-x: 50%;
background-position-y: 50%;
}
</style>
<div class="foo">
<div>
<div></div>
whatever
<div></div>
</div>
</div>
</body>
With this config:
{
"html.format.wrapAttributes": "force-expand-multiline",
//"html.format.contentUnformatted" : "style",
"html.format.unformatted": "style"
}
When we trigger an auto format on the sample html above, the STYLE TAG IS NOT formatted and the style tag content IS NOT changed.
With this config:
{
"html.format.wrapAttributes": "force-expand-multiline",
"html.format.contentUnformatted" : "style",
//"html.format.unformatted": "style"
}
When we trigger an auto format on the sample html above, the STYLE TAG IS formatted (spaces, ident, etc), the style tag content IS NOT changed.

Autohotkey: Replace a text with an icon

How can I replace a text with icon, just as a starter replacing (y) with a thumbs-up icon (like in FB)
So something like
(y)::.....
Your question is missing informations about the scenario where you're working in. Since you have mentioned 'Facebook' I believe you'll need Javascript instead of AutoHotKey. So, here's the two steps to switch letters by icons in a HTML page using Javascript. I hope it can enlighten your ideas:
1- Incorporate an icon library in your HTML's head like <link href="https://fonts.googleapis.com/icon?family=Material+Icon‌​s" rel="stylesheet"> (there's other options besides Google's one around the web)
2- Use Javascript to replace every expression like (Y) by the icon's library code such as <i class="material-icons">thumb_up</i>
Working snippet:
function replace(){
var box = document.getElementById('box');
var str = box.value;
var filterok = str.replace(/\(Y\)/gi, "<i class='material-icons'>thumb_up</i>");
var filtersmile= filterok.replace(/\=\)/gi, "<i class='material-icons'></i>");
var filterHHH= filtersmile.replace(/HHH/gi, "<i class='material-icons'>favorite</i>");
document.getElementById("target").innerHTML = filterHHH;
}
body {
background: lavender;
}
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body onload="javascript: replace()">
<textarea rows="4" cols="50" oninput="replace()" id=box>
Every (Y) and =) and HHH inserted here will be substituted by a match icon.
</textarea>
<br>
<span id=target></span>
</body>
ps: The g on StringReplace stands for 'global' while gi stands for 'global + case insensitive'.
ps2: The \ are used to scape the special chars used on the icons call.
ps3: Google Material Icons List
If you mean to use AutoHotKey to edit the HTML code of a webpage instead, the way to do the same as the example above with AutoHotKey instead of Javascript would be:
FileRead, filevar, page.html
symbolA:="(y)"
symbolB:="=)"
symbolC:="HHH"
StringReplace, filevar, filevar, %symbolA%, <i class='material-icons'>thumb_up</i>, All
StringReplace, filevar, filevar, %symbolB%, <i class='material-icons'></i>, All
StringReplace, filevar, filevar, %symbolC%, <i class='material-icons'>favorite</i>, All
FileDelete, page.html
FileAppend, %filevar%, page.html
return

TYPO3: Automatic wrapping CASE by page.layout

I'm having a big teaser image at the top of the page. The author may select in the backend whether the teaser image should be static or a animated slideshow. I'm using bootstrap for the slideshow btw.
The selection appears at Page > Edit > Appearance
Rootpage TSConfig:
TCEFORM.pages {
layout.altLabels.1 = Default (with Slideshow)
layout.altLabels.0 = Default
}
Now, it gets a bit trickier.
To get the Bootstrap slider running, you need to have an outer wrap and each slide wrapped, too. This is what I've got so far:
page.10.variables {
teaser < styles.content.get
teaser.select.where = colPos = 0
teaser.stdWrap.required = 1
teaser.stdWrap.wrap {
cObject = CASE
cObject {
key.field = layout
default = TEXT
default.value = |
1 = TEXT
1.value = <div id="teaser" ...>|</div> ### shortened
}
}
teaser.renderObj.stdWrap.wrap {
cObject = CASE
cObject {
key.field = layout
default = TEXT
default.value = |
1 = TEXT
1.value = <div class="item">|</div>
}
}
}
The first teaser.stdWrap.wrap works like a charm. Selecting the Frontend Layout wraps the teaser correspondingly.
But the teaser.renderObj.stdWrap.wrap doesn't want to work. Mainly, because I think that the key of the CASE is not the Frontend Layout, but the layout of the content element. How to change that?
Second question. This is how the wraps currently look like (or how they would look if the TS above would work as intended):
<div class="item">
<div id="c14">
<div class="ce-textpic ce-right ce-intext">
<div class="ce-gallery" data-ce-columns="1" data-ce-images="1">
<div class="ce-row">
<div class="ce-column">
<div class="ce-media">
<img src="img.jpg" width="1150" height="632" alt="">
</div>
</div>
</div>
</div>
<div class="ce-bodytext"></div>
</div>
</div>
Is there a way to make it look more or less like this?
<div class="item">
<img class="slide" src="img.jpg">
</div>
The customer doesn't wish to have any captions or text, so it can be ignored.
I'm running TYPO3 7.6.6 with fluid_styled_content.
So the answer for the 1st question:
You can use the "getText" data type in TypoScript. See in doc here.
It has a predefined variable for the current page record. So simple change the second key attribute so:
key.data = page:layout
But if you are running the system with fluid_styled_content, then you can simply use fluid to solve this problem. (There you can access the layout with data.layout )
To answer the second question:
Yes. It is possible, you need to take a look into the fluid_styled_content extension. There you find a lot about the templates, layouts and the elements. You can simply override them with your templates and you can get rid of any not wanted div inside.
To do so, I can recommend you a german video.

Facebook Comments Box/ Twitter Feed broken in angular/symfony web app

I am attempting to build a site using angularJS and symfony, and in my site
I want to add a simple Facebook comments box and twitter timeline shown here, respectively:
https://developers.facebook.com/docs/reference/plugins/comments/
https://twitter.com/settings/widgets/370693822461657088/edit?focus_textarea=1&notice=WIDGET_CREATED
in my JavaScript i have set up angular routing which routes the user to different views, but the problem is the comments box and twitter timeline don't show up in these views.
They DO however, work perfectly fine when they are placed outside of the ng-view tags.
Here is a VERY simplified code snippet of my problem:
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block custom_stylesheets %}
{% endblock %}
</head>
<body>
{% block body %}
<div id = "container">
<!-- twitter and facebook work outside of here -->
<div ng-view>
<!-- but not in here -->
</div>
</div>
{% endblock %}
{% block custom_javascripts %}
{% endblock %}
</body>
</html>
Is there something specific i need to do to get twitter/facebook working?
it seems as if the javascript is broken, the twitter feed still displays a "tweets by #google" link
You need directives because the JavaScript needs to execute whenever some set of DOM elements is present:
(function() {
var createDirective, module, pluginName, _i, _len, _ref;
module = angular.module('FacebookPluginDirectives', []);
createDirective = function(name) {
return module.directive(name, function() {
return {
restrict: 'C',
link: function(scope, element, attributes) {
return typeof FB !== "undefined" && FB !== null ? FB.XFBML.parse(element.parent()[0]) : void 0;
}
};
});
};
_ref = ['fbActivity', 'fbComments', 'fbFacepile', 'fbLike', 'fbLikeBox', 'fbLiveStream', 'fbLoginButton', 'fbName', 'fbProfilePic', 'fbRecommendations'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
pluginName = _ref[_i];
createDirective(pluginName);
}
}).call(this);
I found this one on the internets that handles the Facebook one's in a pretty simple way I believe the definition even stays the same as the original usage, you just do something like:
<div class="fb-comments" data-href="http://pyramidplayersproductions.org" data-width="292" data-num-posts="10"></div><br/>
<div class="fb-like-box" data-href="http://www.facebook.com/pyramidplayersproductions" data-width="292" data-show-faces="true" data-stream="true" data-show-border="true" data-header="true"></div>
You'll still have to roll your own for the twitter feed (or search google for Angular twitter directive and see what surfaces). If nothing does the general formula for building a directive will be:
angular.module("customDirectives", []).directive("myTwitterDirective", function() {
return {
//C means class E means element A means attribute, this is where this directive should be found
restrict: 'E',
link: function(scope, element, attributes) {
//do javascript you need to here to get data or initialize
//twitter. you can access the dom element using element[0]
//element is the angular wrapped element object attributes
//has any HTML attributes like attribute.myAttribute would be 'something if <my-twitter-directive myAttribute='something'>
}
};
});
//probably in another file
angular.module("mainApp", ["customDirectives"]);
Usage would look like:
<my-twitter-directive></my-twitter-directive>
Wrapping this stuff up in a directive keeps the DOM manipulation code out of the services or controllers (and presentation) code, keeping all of them easily testable without the need for an actual browser or dependencies on the view.
I decided to follow my own advice above and I think I'm right:
http://jsfiddle.net/MPnES/
The JS
angular.module("mainApp", []).directive("twitterTimeline", function() {
return {
//C means class E means element A means attribute, this is where this directive should be found
restrict: 'C',
link: function(scope, element, attributes) {
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
}
};
});
The HTML
<body ng-app="mainApp">
<a class="twitter-timeline" href="https://twitter.com/pattonoswalt" data-widget-id="370757361348014081">
Tweets by #pattonoswalt
</a>
</body>

Show one .png image over another .jpg image

I have the following code:
<img style="background: url(./image/data/logo.png) no-repeat top right" src="./image/data/picture.jpg" />
As it is now, it shows the logo.png under the picture.jpg image. How can I make it to be shown above the .jpg image?
Thanks.
You must use 2 images to do that. The img must be with position absolute (The one that you want to be over the other). Don't forget that the container must have position:relative in order to contain the absoluted png.
Here is the example:
http://jsfiddle.net/jNpaH/
The html tags:
<div class="image">
<img src="http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png"
class="png-over" />
<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Papua_New_Guinea_map.png"
/> </div>
The styles:
.image{position:relative}
.png-over{position:absolute; top:0; left:0}
The problem with that technique is that your code becomes spammed with the image tags.
One way of solving it with jQuery is to find each div container with the class 'images' and prepend to each one the image tag.
Here is the example:
http://jsfiddle.net/jNpaH/2/
According to your code I assume that you prefer to have a short html code. But it is impossible to have an image_tag with a background covering it.
The cleanest way is to use jQuery:
This is the final code:
http://jsfiddle.net/QyMkh/
First put a div that will contain all your images. The div must have a class, the images don't require it necessarily.
<div class="image">
<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Papua_New_Guinea_map.png" />
<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Papua_New_Guinea_map.png" />
<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Papua_New_Guinea_map.png" />
</div>
Then add this jQuery block in the html before the closing </body>:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
// store in a variable the url of the image that will be used as background
var url = 'http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png';
// select every image_tag that is children of the div with the class 'image'
jQuery('.image img').each(function() {
// every child image will be wrapped inside generated divs with a class 'img-wrap'
$(this).wrap('<div class="img-wrap"></div>');
});
// After the images are wrapped, insert the image tag that will work as background, note that instead of using the source I'm using the variable that stores it.
$('<img src="' + url + '" class="logo" />').prependTo('.img-wrap');
</script>
Finally add those style declarations to get the desired effect.
<style type="text/css">
.img-wrap{position:relative}
.img-wrap img.logo{position:absolute; top:0; left:0}
</style>
This code will keep your html documents with no unnecesary markup when you try to edit next time.
An advantage of using an image_tag as a background, is that with css you can resize its width and height. Try adding this new rule of stylesheet:
.img-wrap img.logo { height: 170px; left: 75px; position: absolute; top: 50px; width: 170px}
To end this, if you want more flexibility, for example you don't want the image_tags be container in a div, do this actions: replace this line of the jQuery block:
jQuery('.image img').each(function() {
with this
jQuery('.image').each(function() {
and add a class="image" to each
<img class="image">