Title: Twitter Image Host
Author: michaeltyson
Published: <strong>January 9, 2010</strong>
Last modified: August 7, 2011

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://s.w.org/plugins/geopattern-icon/twitter-image-host.svg)

# Twitter Image Host

 By [michaeltyson](https://profiles.wordpress.org/michaeltyson/)

[Download](https://downloads.wordpress.org/plugin/twitter-image-host.0.6.1.zip)

 * [Details](https://pcm.wordpress.org/plugins/twitter-image-host/#description)
 * [Reviews](https://pcm.wordpress.org/plugins/twitter-image-host/#reviews)
 *  [Installation](https://pcm.wordpress.org/plugins/twitter-image-host/#installation)
 * [Development](https://pcm.wordpress.org/plugins/twitter-image-host/#developers)

 [Support](https://wordpress.org/support/plugin/twitter-image-host/)

## Description

Keep your traffic in the family! Host Twitter images on your own site, with support
for comments and trackbacks, image
 resizing and thumbnailing with Lightbox.

Twitter doesn’t yet come with its own inline image support, so we tend to be limited
to using image hosting services,
 and linking to them with short URLs. So, services
like Twitpic host the image, and we direct traffic to them in return.

Better to take advantage of that traffic, and host images on your own site. This
way, viewers come to your site, instead
 of someone else’s!

Posted images are displayed in your normal WordPress template, with support for 
comments and trackbacks, without any
 setup required. Most themes should work with
this, but if not, or if a different layout is required, a custom theme template 
can also be provided (see ‘Creating a Template’).

Provides an HTML form for posting image content, as well as an API modelled on that
of [img.ly](http://img.ly/pages/API),
 compatible with Tweetie (for iPhone) and 
any other Twitter clients that speak this protocol and offer configuration of custom
image hosting services.

Uses Twitter’s authentication and a list of authorised accounts, so you can let 
others use your image host too. You can even
 post status updates to Twitter while
submitting images.

Provides a widget and shortcode to display uploaded images. This supports filtering
by Twitter account, styling with CSS,
 and Lightbox/Thickbox.

### Widget

To use the widget, simply visit the Widgets page and drag the “Twitter Images” widget
into a sidebar and configure it.

### Shortcode

Shortcodes are snippets of text that can be inserted into pages and posts. These
snippets are replaced by various generated content.
 Twitter Image Host provides
a ‘twitter-images’ shortcode to display images you have uploaded within a page/post.

Available parameters:

    ```
      count                    Number of items to display
      id                       Single ID (eg 'abcde') of one image to display, or multiple IDs separated by commas (abcde,fghij)
      view                     Image thumbnail view: squares, proportional, large or custom
      custom_thumbnail_width   Custom width for thumbnails, when 'view' is 'custom'
      custom_thumbnail_height  Custom width for thumbnails, when 'view' is 'custom'
      custom_thumbnail_crop    Whether to crop custom thumbnails
      author                   Comma-separated list of Twitter account names to limit results to
      columns                  Number of columns of images to display 
      lightbox                 'true' to use Lightbox/Thickbox
    ```

Example:

    ```
      [twitter-images columns=4 lightbox="true"]<h3>PHP function</h3>
    ```

As well as the shortcode, you can also use call `twitter_image_host_images()` from
within a template to
 produce the same output. Pass the same arguments as the shortcode
as associative array values:

    ```
      <h3>Recently submitted images</h3>
      <?php twitter_image_host_images(array('author' => 'ATastyPixel', 'columns' => 6, 'lightbox' => true)); ?>
    ```

Tip: Use this in the `twitter-image-host.php` template (see ‘Creating a Single Template’,
below) to display
 other posted images when viewing an image. Use `the_twitter_image_author()`
to filter the list, to show only other submissions by the same Twitter account as
the one of the currently displayed image.

### Template Tags

This plugin provides several template tags, for use both in displaying single posts(
see ‘Creating a Single Template’), and for custom pages which display
 many posts
in a loop (see ‘Using Template Tags in a Loop’).

The available template tags are:

#### Single Entry Tags

_`the\_twitter\_image\_permalink`_

Returns the URL to the view page

_`the\_twitter\_image\_url`_

Returns the full URL to the image, or the image thumbnail if the original image 
was large

_`the\_twitter\_full\_image\_url`_

Returns the URL to the full-sized image, if one exists, or false otherwise

_`the\_twitter\_image\_title`_

The title of the image

_`the\_twitter\_image\_date`_

The date (timestamp) of the image – use date() to configure the display

_`the\_twitter\_image\_author`_

The associated Twitter account

_`the\_twitter\_image`_

Returns HTML to display the image and a link to the full-sized image if it exists,
with Lightbox rel tags.

#### Loop Tags

_`query\_twitter\_images`_

Search for Twitter images

Available parameters (passed as associative array):

    ```
     count                    Number of items to display
     id                       Single ID (eg 'abcde') of one image to display, or multiple IDs separated by commas (abcde,fghij)
     author                   Comma-separated list of Twitter account names to limit results to
    ```

_`has\_twitter\_images`_

Use with loop: Determine if there are more images

_`next\_twitter\_image`_

Use with loop: Get the next image

#### Creating a Single Template

By default, this plugin will use the standard post template (‘single.php’). However,
if you wish, you can create a
 custom template to display hosted images. The template
should be called ‘twitter-image-host.php’, located within your current theme directory.

Creating a template to use this information is fairly straightforward if you have
just a little knowledge of HTML or PHP:

 1. On your server (via an FTP program, etc.), navigate to your current theme. This
    will live within `wp-content/themes`.
 2. Copy an existing template – `single.php` is usually a good candidate – and call
    it `twitter-image-host.php`.
 3. Open up `twitter-image-host.php`, and delete everything that looks post-related:
    This usually includes everything between
     the `have_posts` call and the matching`
    endif`, and may include some other surrounding content like an ‘Edit this post’
    link.
 4. Replace that which you have just deleted with something that uses the ‘single entry’
    template tags above, like the following:
 5.     ```
        <?php echo the_twitter_image() ?>
        <h1 class="center"><?php echo the_twitter_image_title() ?></h1>
        <p class="center">
            From <a href="http://twitter.com/<?php echo the_twitter_image_author() ?>"><?php echo the_twitter_image_author() ?></a>
             on <?php echo date('F jS, Y', the_twitter_image_date()) ?>
        </p>
        ```
    
 6. Save the file, add some content (see the ‘Posting Images’ section), and see how
    it looks.

#### Using Template Tags in a Loop

Just like the WordPress Loop template tags, the template tags provided by this plugin
can be used to display multiple posted entries.
 This can be used to create a custom
page template that lists all submitted entries, with more flexibility than that 
offered by the shortcode.

Use begins with a call to `query_twitter_images()`, possibly with an argument to
configure the search. If the result is true, then the loop begins,
 conditional 
upon `has_twitter_images()`, and starting with `next_twitter_image()` to load the
next entry. The single template tags can then be used to customise the display of
each entry.

Here is an example of use:

    ```
      <?php if ( query_twitter_images() ) : ?>
          <?php while ( has_twitter_images() ) : next_twitter_image(); ?>
              <div class="item entry">
                <div class="itemhead">
                  <h1><a href="<?php echo the_twitter_image_permalink() ?>" rel="bookmark"><?php echo the_twitter_image_title(); ?></a></h1>
                  <div class="date"><?php echo date('F jS, Y', the_twitter_image_date()) ?></div>
                </div>

                <?php echo the_twitter_image() ?>
                <p class="center">From <a href="http://twitter.com/<?php echo the_twitter_image_author() ?>"><?php echo the_twitter_image_author() ?></a></p>
                </div>
          <?php endwhile; ?>
      <?php else : ?>
          <p>There are no Twitter images.</p>
      <?php endif; ?><h3>Posting Images</h3>
    ```

To start posting from your WordPress blog, select the “Twitter Image Host” menu 
item from the “Posts” administration section.
 Enter a title for your image, select
your image file, hit Submit, and you will be given the URL for the image. If you
wish to tweet straight from this facility, you will need to follow the instructions
from that page to set up the plugin.

To access this facility from an application, use the access point displayed on the
Twitter Image Host options page under “Settings”.

The API is more-or-less the same as that of [TweetPic](http://twitpic.com/api.do),
[img.ly](http://img.ly/pages/API), etc.

To post from Twitter (Tweetie 2) for iPhone, visit Twitter/Tweetie’s settings, and
within _Services, Image Service_, select ‘Custom’, then
 enter the API URL as listed
on the options page.

### Making the URL even shorter

If you run WordPress from a sub-directory (for example, http://your-site.com/blog),
then the short URLs generated by this plugin will
 look like `http://your-site/blog/
xxxxx`. You can remove that ‘blog’ component via a little `.htaccess` trickery.

Here’s how:

 1. Create and open a new file in your site’s webroot called “.htaccess”. If there’s
    one already there, just open that up and prepare to edit at the bottom.
 2. Add the following, replacing ‘blog’ with the real subdirectory under which WordPress
    is installed:
 3.     ```
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
        RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/twitter-image-host-content/%1.jpg -f [OR]
        RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/twitter-image-host-content/%1.png -f [OR]
        RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/twitter-image-host-content/%1.jpeg -f
        RewriteRule (.*) /blog/$1 [L]
        </IfModule>
        ```
    
 4. This will take any requests that:
 5.  * Are located in the web-root (start with a slash, followed by anything but a 
       slash until the end)
     * Have a corresponding file within Twitter Image Host’s content directory
        Then,
       it’ll rewrite the request silently to the real Twitter Image Host URL, without
       the viewer seeing.
 6. In Twitter Image Host settings, set the ‘Override URL Prefix’ option to ‘http://
    your-site.com/’

### Credits

German Translation: [Walter Güldenberg](http://mb.walter.silvergeeks.com/)

## Installation

 1. Unzip the package, and upload `twitter-image-host` to the `/wp-content/plugins/`
    directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Visit the settings page and add your Twitter account to the list of authorised 
    accounts
 4. Start submitting images – See the ‘Posting Images’ section for more

If you find Twitter Image Host useful, please consider buying some awesome [Mac/iPhone software](http://atastypixel.com/products).
Then
 tell all your friends.

## FAQ

  I get “Couldn’t place uploaded file” messages

You probably need to create the folder in which Twitter Image Host stores uploaded
images — it will try to create the folder automatically, but it will fail if it 
doesn’t have permission.

Create a folder called `twitter-image-host-content` within the `wp-content` folder
of your WordPress installation, and make sure it has write permission for the web
server user.

  I keep getting 404 errors

Make sure your blog is using URL rewriting (i.e. your permalink structure is anything
but the boring default `?p=###`).

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Twitter Image Host” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ michaeltyson ](https://profiles.wordpress.org/michaeltyson/)

[Translate “Twitter Image Host” into your language.](https://translate.wordpress.org/projects/wp-plugins/twitter-image-host)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/twitter-image-host/),
check out the [SVN repository](https://plugins.svn.wordpress.org/twitter-image-host/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/twitter-image-host/)
by [RSS](https://plugins.trac.wordpress.org/log/twitter-image-host/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 0.6.1

 * Added automatic mapping between Twitter account and author (users prior to 0.6.1
   must re-login to Twitter to take effect)
 * Added German translation, thanks to [Walter Güldenberg](http://mb.walter.silvergeeks.com/)
 * Improved internal query handling

#### 0.6

 * Updated Twitter authentication support, and moved posting interface to WordPress
   Admin.

#### 0.5.7

 * Support for Twitter for iPhone 3.0.1 bug (see ‘Posting Images’ section in readme)

#### 0.5.6

 * Fixed bug that causes ‘not found’ error when appending any parameters to the 
   URL, or a trailing slash

#### 0.5.5

 * Better error reporting for failed uploads

#### 0.5.4

 * Fixed bug that prevented filtering based on author from working

#### 0.5.3

 * Avoid adding duplicate images – if a duplicate is detected, just returns the 
   URL to the original image

#### 0.5.2

 * Fallback to index.php template if ‘single’ template can’t be found

#### 0.5.1

 * Added character counter to HTML submission form
 * Bugfix for when content folder doesn’t exist

#### 0.5

 * Implemented a widget, shortcode and standalone PHP function to display uploaded
   images (see documentation)
 * Implemented loop-style template tags to create custom pages for displaying entries

#### 0.4.4

 * Fix to HTML submission form for WP installations within a sub-directory
 * If a tweet is too long, report by how many characters

#### 0.4.3

 * Minor tweak to suppress missing argument warnings

#### 0.4.2

 * Improved Twitter error reporting
 * Fixed bug causing incorrect API response

#### 0.4.1

 * Bugfix in URL creation

#### 0.4

 * Improved support for running out of a sub-directory

#### 0.3

 * Fixed bug that interferes with some other plugins

#### 0.2

 * Proper support for trackbacks, comment feeds, fixed a bug which caused plugin
   to say Twitter was unavailable when the Twitter account has no direct messages

#### 0.1

 * Initial release

## Meta

 *  Version **0.6.1**
 *  Last updated **15 years ago**
 *  Active installations **10+**
 *  WordPress version ** 3.0 or higher **
 *  Tested up to **3.2.1**
 *  Language
 * [English (US)](https://wordpress.org/plugins/twitter-image-host/)
 * Tags
 * [Hosting](https://pcm.wordpress.org/plugins/tags/hosting/)[images](https://pcm.wordpress.org/plugins/tags/images/)
   [twitter](https://pcm.wordpress.org/plugins/tags/twitter/)
 *  [Advanced View](https://pcm.wordpress.org/plugins/twitter-image-host/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/twitter-image-host/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/twitter-image-host/reviews/)

## Contributors

 *   [ michaeltyson ](https://profiles.wordpress.org/michaeltyson/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/twitter-image-host/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](http://atastypixel.com/blog/wordpress/plugins/twitter-image-host)