Articles
Echo Images inside a Post into the Loop
Here is a useful trick. Want to call or echo an image into your blog post with our using the custom fields? Well this could be tricky, but I know of a way.
All you have to do is print these lines of code into your
index.php
or home.php
inside the loop:
<?php $id =$post->ID; $the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id"); $home = get_option('home'); $pattern = '!<img.*?src="'.$home.'(.*?)"!'; preg_match_all($pattern, $the_content, $matches); $image_src = $matches['1'][0]; ?>
then after write:
<?php if($image_src != '') { ?> <a href="<?php echo the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a><br /> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php echo $image_src; ?>" alt="<?php the_title(); ?>" /></a> <?php } ?>
That’s all! This will look for the first image in your post and echo it in the loop, could be used to show off those pretty thumbnails for the post..
LAWPUG
April’s new meetup location for LAWPUG
Anyone in the Los Angeles area? Well the first Sunday of the month is the LAWPUG, and since the weather is nice in LA, the meet is going to be held at the farmers marking on 3rd. For more info head over to LAWPUG.org.
Guest Post
‘Portal’ And ‘Left 4 Dead 2’ Arrive On Linux
Steam is powerful, hot, and painful. It can move trains, boats, and has driven minds crazy with the power of invention. And now, the power of steam has come to Linux. That’s right, Linux. Until recently Linux users were the most unloved members of the gaming world. They have been the outcasts, the rejects in the corner who preferred an operating system, which quite frankly, is the most logical of all of them. They are Linux users. And now, they have arrived.
Ok, enough with the dramatics; Portal is available if you’re running Valve’s Linux Steam client, you’ve got it. If you don’t have it, get it, because the Steam Box is coming. While PC, Xbox, Play Station, and Mac users have all had a gaming advantage, the love for Linux users has never been there. Until now.
Linux gamers now have access to Valve’s Half-Life,Half-Life: Blue Shift, and the just-released beta Left 4 Dead 2 (L4D2). And that’s good news.
For all the mega super awesomeness that this news could potentially be, it’s not quite the best. Valve’s current catalog for Linux is still quite sparse. With only 13 titles as of this article, it’s barely a scratch against the wall of Mac and PC game titles out there, but hey, it’s a start. I mean, Portal is a game from 2007, and the original Half-Life was first published in 1998.
This padding of the Linux library is likely part of preparations for the Steam Box console, which is expected to run the OS. Valve’s entire catalog will probably be available for Linux before long. The question is whether any other big-name developers will follow suit. There are over 100 Linux titles on Steam right now, but most of them are smaller games from indie developers. The Steam Box may have to stream games from a Windows-equipped PC if it wants to offer a similar selection of blockbusters to next-generation consoles.
Now, Remember that Valve utilizes a Direct3D -> OpenGL layer for its ports. It takes the D3D9 with extensions and dynamically created oGL calls. Not only does have to call oGL but it also has to deal with that translation overhead. Despite that, it still ends up being faster than native DX where no translation is done.They still use d3d9 but go through live translation to oGL calls and still they outperform the native DX9 implementation despite having the same limitations. Faster than native despite having additional translation overhead is nothing short of impressive especially when you consider Valve had next to no oGL experience when they started this ( although then basically then hired an all-staroGL team to carry out the endeavor.
It’s hard to talk about the Linux OS without talking about the Steam Box, which, if you believe Valve head Gabe Newell, is the console killer. Newell has confirmed that Valve’s own Steam Box will come packaged with Linux. The OS is anathema to the walled gardens of Windows, being both free and open-source. It’s just as alien to the Xbox and Playstation front-ends. Where they curate content and load up with adverts, the Steam Box is as open as an average PC.
Newell says you’re free to install Windows on Valve’s Linux box, and download whatever you fancy. Imagine a console with Adblock. Imagine a console that isn’t hamstrung by its components half a decade down the line, a console that doesn’t force its creator to make a loss on each sale or to devote a gigantic chunk of budget half way through its life cycle to make its successor.
The Steam Box should scare console makers. 2012 was a monster year for PC gaming, the portents of doom that dogged the platform for years finally shaken off as the once dominant consoles felt their teeth grow too long.
With the upcoming Steam Box, and Portal and Left for Dead 2 coming to Linux, the rise of the few should be a concern to all.
Author Bio: The article is written by Jason Phillips, a freelance writer and an enthusiast. His passion about gaming inspired him to write gaming articles, blog about gaming and starting an online gaming site Zombie Games 365.
Plugins
Swekey: A safe web enabler usb?
I received a Swekey in the mail this week. What’s a Swekey you ask?
Like regular keys protect your car and your home against thieves and burglars, the swekey protects your internet accounts against any kind of piracy
Any swekey protected web site will never accept to log you in if your swekey is not plugged into your computer… Read more
So I am going to start off by stating that there is a WordPress plugin to enable this handy little USB key on WordPress powered sites. For information on the plugin you can visit it on the plugin directory.
Hopefully you’re using the latest WordPress install (2.7.1), in which you can head to the plugins menu and click on Add New. Do a search for Swekey and install the latest version (which at the time of writing this was version 1.0.7).
Once you’ve got the latest version installed head into your settings and find the Swekey setting page which will look like:
I’m going to have to do some research on the first three options in the setting page, which I am not sure what other server URL I’d use or if needed be outside the localhost (which I am assuming is default — or left blank as it states).
The fourth option asks you whether you want to accept regular login’s without the swekey (in cause of misplacement) or to only allow login access with the swekey. For the most part I would not choose the latter option as the swekey isn’t that popular. This also might only be handy at the current state to the people inside the development of the Swekey, but a good idea none the less.
The next option inside the setting panel will either allow or disallow your users to attach/detach there profiles with the swekey to your site. If you’re site doesn’t allow users to register and you hand register everyone, you may want to do the same with this option.
Second to last, you can edit the Supported Brands: 8 chars hexadecimal upper case value. Which at this time am not sure what it does..yet.
The last option is simply a placement for the swekey logo if you choose to upload one.
So now we’ve got the plugin installed, I guess I better get to using and testing it before continuing anymore.. 🙂
-
Tips & Tricks4 months ago
WordPress Security Hacks
-
Pages1 month ago
Write For Us – Guest Post
-
Showcase2 months ago
StylizedWeb.com
-
News4 weeks ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks3 months ago
How to: show/hide a widget in WordPress with jQuery
-
Tips & Tricks1 week ago
Remove the title attribute using jQuery
-
Plugins3 months ago
Top Membership plugins
-
Tips & Tricks1 month ago
Limit the characters that display on the_title
Austin
December 8, 2008 at 3:54 am
Assuming the image has been added using the WP uploader, here’s a way of doing the same thing using the WP API, which might have a performance advantage:
<?php $attachments = (array) get_children(array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’));
if ( ! empty( $attachments ) ) :
$attmt = array_shift($attachments);
$image_thumb = wp_get_attachment_thumb_url($attmt->ID); ?>
<a href=”<?php echo the_permalink() ?>” rel=”bookmark” title=”Link to <?php the_title(); ?>”><?php the_title(); ?></a><br />
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><img src=”<?php echo $image_thumb; ?>” alt=”<?php the_title(); ?>” /></a>
<?php endif; ?>
frosty
December 8, 2008 at 10:59 am
Thanks for that one!
Picsbuzz
January 7, 2009 at 9:57 pm
This is great script, it helps me a lots!!! Thank you so much!!
I wonder if this script can grab the first image in the post which hosted on share host like: flickr or imagesharkus?
frosty
January 7, 2009 at 10:05 pm
Your welcome, I am not sure. If we could find out details to their database it may be possible.
Nick
January 15, 2009 at 12:38 pm
That can be useful
Nick’s last blog post..Montana Library
Thomas
August 10, 2009 at 11:00 am
Hi all,
First of all, very nice script. I noticed that the output was in html (ie, img src and thumbnailing).
Does anyone know of any snippet to be able to echo the image via php, without having to name the actual individual image file (eg. tree.jpg), and instead using a variable from a database that names photos in a directory.?
thanks
tom
Maor
September 5, 2009 at 5:33 pm
Thanks for the tip, liked it!
.-= Maor´s last blog ..וורדפרס 2.8+: איך לא להציג קטגוריות מסוימות בתפריט הצדדי? =-.