Controlling the Image Choice When Sharing with Facebook

Recently I had a client who wasn't happy with the images Facebook was providing as options when a user shared one of their product pages with Facebook.

You can give Facebook hints on what images you would like them to use.

Just add this code to your page for the images you would like to be in the selection:

<link rel="image_src" type="image/jpeg" href="http://example.com/images/my-image.jpg"/>[/prettify]

In my case, the image I defined here was the first choice that appeared on Facebook.

You can define more than one image for the available options.

Printing or Rendering a Node Field or Profile2 Field in Drupal 7

When overriding a node template or user profile, you should not be drilling down the field array and printing the output unless you have a very good reason to do so. i.e. (do not do this) print $node->field_zipcode['und']['0']['value'];

The Drupal 7 field api offers us the field_view_field() function to get a renderable array of the output for a field entity.

Fixing file system permissions

Have you ever shelled into a file system where a bunch of files were executable that should not be? Or maybe permissions are generally a mess?

Typically within a website file system, files should be 644 (owner read/write, group & all just read) and directories should be 755 (owner read/write/execute, group and all just read/execute).

If you don't have any special needs for individual files to be executable, or you just want to start fresh, you can use this method.

Adding a CCK Field to a Custom Form

Recently I wanted to add a CCK combo field into a custom form. Why would you need to do this? Well, my reason was to re-use a combo field with the 'add another item' functionality. Using the node form was not an option.

In this example we have a CCK combo field named "guests". Each guest has a first name, last name, and email address. The content type the guests field is in is my_event.

When adding this code to your form function, the guests field will display just as it does on the node form.


// include the content file

Drupal 7 Get Image Style Path

Today I was working with the new image styles (imagecache) in Drupal 7.

I created a content type with an image field and needed to embed the image style path inside custom HTML for a JQuery slideshow. That was the reason I needed to get the path vs using the theme image function.

The trick was using image_style_url().

<?php
$path = image_style_url('home_rotator', $node->field_slideshow_image[LANGUAGE_NONE][0]['uri']);
?>

Drupal 6 to 7, a first glimpse

Today I finally started porting a module over to Drupal 7. I didn't read up in depth on the changes and just dove in and started learning based on the PHP errors and features that were not working.

I'm not going to go into anything too in depth here as there is good information out there already, but I took some notes and will point out some changes I had to make with the module I was working on.

Admin settings path

Spokeo a Spam Source?

About a week ago my sister sent an email out to her family and friends because she was surprised to see her name and former address listed on www.spokeo.com. She advised everyone to de-list their info.

I searched for my name and found normal info that would be public record. I wasn't too alarmed by this and didn't proceed to attempt to de-list my information.

Today however, I was wondering what it took to de-list your name. More specifically, I was wondering if they request email addresses.

Backup the old database before you create a new one

Maybe this is more a 'note to self' than anything else. No matter how much you think you won't need a database when you drop it, just make a backup before you do anyway.

Today for example, there is a server which has 2 environments on it: dev.example.com and staging.example.com. The client said they had pending changes on staging. We knew the client was only working on one environment.

So I thought it was safe to copy the staging environment over to dev, and I did!