-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
71 lines (53 loc) · 2.21 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* The main template file.
*
* This theme is purely for the purpose of testing theme options in Options Framework plugin.
*
* @package WordPress
* @subpackage Options Check
*/
get_header(); ?>
<article>
<header class="entry-header">
<p>Responsive + Images = </p>
<h1>Responsage</h1>
</header><!-- .entry-header -->
<div class="entry-content">
<h3>About</h3>
<p>This is a small WordPress theme plugin that allows you to make your images responsive. It detects the user-agent string of the browser (Thanks to <a href="http://code.google.com/p/php-mobile-detect/">Mobile Detect</a>) and returns the url of the resized image.</p>
<h3>How to Include in Your Own Project</h3>
<p>Just drag the responsage folder of this theme and functions.php into the theme of your choice.</p>
<p>To use Responsage, call the function ra_attachment_image_src in your template files with the image ID and size to produce the image URL.</p>
<hr>
<h3>Example Code</h3>
<pre>
<?php query_posts( array('post_type' => 'post', 'posts_per_page' => 5) );
if (have_posts()) : while (have_posts()) : the_post();
$image_url = ra_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
?>
<div class="post">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) : ?>
<img src="<?php echo $image_url; ?>" />
<?php endif; ?>
</a>
</div>
<?php endwhile; endif; ?>
</pre>
<h3>Adding Sizes</h3>
<p>Simply add another array with the relevant data to add an image size to your theme.</p>
<pre>
//Called in the functions.php file
ra_add_image_size("widget", 400, 400, 250, 250, false);
ra_add_image_size("post", 1200, 900, 640, 480, false);
ra_add_image_size("gallery-portfolio", 300, 300, 300, 300, true);
//Update the default WordPress sizes to include mobile equivalents
ra_update_image_size("full", 960,960,false);
ra_update_image_size("large", 576,576,false);
ra_update_image_size("medium", 288,288,false);
ra_update_image_size("thumbnail", 100,100,true);
</pre>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php get_footer(); ?>