Jetpack

How to add a default fallback image if no image can be found in a post

When you publish a new post on your site, Jetpack crawls it and looks for images that can be used when sharing that post on Facebook, on Twitter, or if that post appears in the Top Posts and Pages widget in your sidebar.

Jetpack starts by looking for a Featured Image. If you didn’t define any, we will look for slideshows and galleries, and then for single images you may have inserted in your posts. If you’ve inserted an image that is hosted on another site, we can use it too.

However, sometimes you may not have added any image to your post. In such cases, you can add this code snippet to your theme’s functions.php file, or in a functionality plugin. This way, your readers will see a default image when sharing that post on Facebook, for example:

function jeherve_custom_image( $media, $post_id, $args ) {
	if ( $media ) {
		return $media;
	} else {
		$permalink = get_permalink( $post_id );
		$url = apply_filters( 'jetpack_photon_url', 'YOUR_LOGO_IMG_URL' );
	
		return array( array(
			'type'	=> 'image',
			'from'	=> 'custom_fallback',
			'src'	=> esc_url( $url ),
			'href'	=> $permalink,
		) );
	}
}
add_filter( 'jetpack_images_get_images', 'jeherve_custom_image', 10, 3 );

It’s worth noting that the fallback image has to be larger than 200 x 200px, as per Facebook requirements. If your image is smaller, Facebook will ignore it.

Reference

Posted in Code snippets, Tips & Tricks | Tagged , , , , | Comments Off

Jetpack 2.5: Google Integration, VideoPress, and Facebook Embeds

In the latest update to Jetpack, we have some exciting new features to share with you including integration of Google services and products, adding VideoPress to our list of modules, and the ability to embed your Facebook updates into your blog posts. Let’s take a closer look at each of these new features!

(more…)

Posted in Releases | Tagged , , , , | 38 Comments

How to add a custom Open Graph image tag to your home page

When you share a post on Facebook, or when Jetpack Publicize publishes a post to your Facebook page, Facebook crawls the page and looks for Open Graph meta tags to build a complete post preview (with an image, title, description, …).

Jetpack automatically creates these meta tags for you, so you don’t have to worry about it!

However, Jetpack doesn’t create any image meta tag for your home page.
If you want to add your own custom image meta tag there, you can add this code to your theme’s functions.php file, or to a functionality plugin:

function fb_home_image( $tags ) {
	if ( is_home() || is_front_page() ) {
		// Remove the default blank image added by Jetpack
		unset( $tags['og:image'] );

		$fb_home_img = 'YOUR_IMAGE_URL';
		$tags['og:image'] = esc_url( $fb_home_img );
	}
	return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'fb_home_image' );

It’s worth noting that the fallback image has to be larger than 200 x 200px, as per Facebook requirements. If your image is smaller, Facebook will ignore it.

Posted in Code snippets, Tips & Tricks | Tagged , | 1 Comment

Remove Jetpack’s Open Graph meta tags

If you’ve activated the Sharing or Publicize module, Jetpack will automatically add Open Graph meta tags to each one of your posts. These tags are used by Facebook to gather information about the post and build a post preview when one of your readers shares a post on Facebook.

If you already use another plugin to handle Open Graph meta tags on your site, we’ll automatically deactivate Jetpack’s Open Graph meta tags for you, to avoid any duplicates.

If, however, you’ve added these tags to your theme or built your own plugin, you’ll want to add the following code to your theme’s functions.php file or to your plugin, to deactivate Jetpack’s Open Graph meta tags:

add_filter( 'jetpack_enable_open_graph', '__return_false' );
Posted in Code snippets, Tips & Tricks | Tagged , , , | Comments Off

Jetpack 2.0: Publicize to Facebook, Twitter, LinkedIn, Tumblr; Post by Email; Photon; Infinite Scroll

The past nine releases of Jetpack have started to reveal our vision for next-generation features that will boost WordPress’ incredible success by making it more social, more connected, more mobile, and more customizable.

Over three million downloads later, we’re excited to report that the community has embraced this seemingly impossible vision for combining the best of hosted and non-hosted WordPress. This tenth release brings some of the most-asked-for features into the hands of millions of Jetpackers.

Publicize to Twitter, Facebook, LinkedIn, Tumblr…

You no longer have to jump through hoops and developer portals to connect your blog to your friends on your favorite social networks. Through Jetpack and your WordPress.com account, you can connect to each network with just a few clicks and broadcast to your audiences and followers across several networks, making WordPress your true digital hub. Activate Publicize from the main Jetpack page in your dashboard, then go to Settings → Sharing to add social sharing connections.

Post by Email

If you live in Gmail, Outlook, your BlackBerry, or just find it easiest to email on the go, you’ll love the new Post by Email feature. Email anything to your secret address — a photo, a video, a bunch of photos, an audio file, ten pages of single-spaced text — and we’ll figure out how to make it beautiful and put it on your blog literally within seconds after you send it. Combined with Publicize and the previously-released Subscriptions module, that post will go out to all your friends including ones that subscribe via email, completing the loop of email / blog nirvana. To set up your special address go to Users → Your Profile in your dashboard and click the “Enable Post By Email” button.

Photon Your Images

Have you ever switched themes to find that full-width images break out of the layout and no longer fit your theme? Are you frustrated that images on your blog take too long to load? Jetpack Photon fixes all of that by making the advanced image acceleration and image editing service from WordPress.com available to the broader WordPress community, essentially making every image a fully dynamic object that themes and plugins can transform to their heart’s content without killing your server. In fact, if you enable Photon, you will see your CPU and bandwidth usage plummet as images are served through the global WordPress.com cloud, meaning less load on your host and faster images for your users.

Infinite Scroll

Infinite Scroll brings the future of reading on the web to your website. Speed and performance are key, and Infinite Scroll loads new content quickly without a full-page refresh. Instead of the old way of navigating down a page — by scrolling and then clicking a link to get to the next page and waiting for the page to refresh — infinite scrolling pulls the next set of posts into view automatically when the reader approaches the bottom of the page. Your theme needs support for this to work. There are already several themes in the directory with Jetpack Infinite Scroll support and theme authors will find documentation for adding it to any theme on jetpack.me.

Onwards…

Jetpack 2.0 isn’t just about shiny new things, we’ve also fixed dozens of bugs and under-the-hood things to keep Jetpack one of the smoothest running, most secure, and most stable plugins out there.

I want to personally thank all of the members of the Jetpack community who have shared countless hours of testing, feedback, and criticism. Your thoughts and passion have made the plugin immeasurably better than it would have been otherwise, and rest assured we’re still listening closely to your feedback around better stats, module activation and deactivation, developer mode, translation, and documentation.

Posted in Features, Milestone, Releases | Tagged , , , , , , , , , | 90 Comments
Follow

Get every new post delivered to your Inbox.

Join 61,642 other followers