Photoshop Variables: How to Import External PSD Smartly

When working on large projects, with many mock-ups and style-sheets, even the smallest change on a re-occurring component can take quite some time. Going through the many mock-ups and adjusting a color or font on that re-occurring component can be a grueling task. If you have an intern that does those things for you, you are in luck, but what about us freelancers?

Photoshop Variables

Do we just sit there and endure the pain? Well, not anymore! A while back, I discovered a system that enables designers to say goodbye to opening 23 PSD files just to change the header color. Instead, we can work smart, like our counter parts the developers, and import external files with something called - “Variables”.

This allows us to put the re-occurring component into one external file and simply import that file into all of our mock-ups. When a change is required, we can just change it in one place.

What is a Photoshop Variable?

Here is Adobe’s technical explanation for a variable. A variable is basically used to define which elements in a template change. There are three ways to define a variable.

  1. Visibility Variables - Shows or hides the content of a layer.
  2. Pixel Replacement - Variables that replace the pixels in the layer with pixels from another image file.
  3. Text Replacement - Variables that replace a string of text in a type layer.

You can read more about variables here: Photoshop Define Variables

For our needs, we are going to focus solely on Pixel Replacement, since what we want to do is import an external style-sheet into our PSD.

Lets Get Started

Step 1 - Setting up your files

In this step we need to decide which component in our homepage deserves a variable. In most cases, it is better off creating a variable for a component that re-appears in many different mock-ups. These components can be headers, footers, various sidebar widgets, and anything that re-occurs in the project. In our example, we will use the global header.

Welcome

There are usually many different states to a component (for example, most common is logged in / logged out). This being the case, style-sheets are created for the component, illustrating the states. Ideally, we want to import the component’s style-sheet and make it fit seamlessly into the mock-up. This will provide us with one file acting both as a style-sheet, and as an embedded file that will be imported into all the mocks the component appears in.

Component Global Header

I have created a fake style-sheet for the global header called 'Component_GlobalHeader.psd'. To continue on with the rest of the steps, please download it below.

Step 2 – Setting up grounds

Let’s open our homepage mock-up and create a new layer. We will give it the same name as the style-sheet's file name, in our case 'Component_GlobalHeader.psd'. Let’s call this new layer 'Component_GlobalHeader'. This is the layer we will be importing the external file to.

Setting Up Ground

Step 3 – Creating the variable

Now it’s time to create the variable. We do this by going to image > variables > define. A popup will appear and we are going to edit some of the parameters.

First of all, always double check that the layer is indeed the correct one (the one we just created). You can check that in the ‘Layer’ field. If it is the incorrect layer, it may cause a bit of a mess later on.

Variable Menu

Since we are focusing on importing, we will go straight to the 'Pixel Replacement' option. In the 'Name' field, enter the same name as the layer and external style-sheet. It is healthy to keep every name the same as this will help with organization in the future.

Creating The Variable

Next, we are going to focus on ‘Method’. We are going to choose a method for scaling the replacement image/file. There are a few options here:

  1. Fit - scales the image so that it fits in the bounding box (which may leave parts of the bounding box empty).
  2. Fill - scales the image so that it fills the bounding box entirely (which may cause the image to extend beyond the bounding box).
  3. As Is - applies no scaling to the image.
  4. Conform - scales the image disproportionally so that it fits in the bounding box.

What we want is 'As Is' since we do not want to manipulate our external style sheet.

Pixel Replacement

The 'Alignment' can be left as the default middle, but this is a personal preference as well as a component consideration. I have aligned top-left in the past as well. It really depends on you.

Let’s leave 'Clip to Bounding Box' unchecked.

Click Next.

Step 4 – The actual importing

In order to import the file, we need to either choose or create a new 'Data Set'. Data sets are collections of variables and associated data. You define a data set for each version of the graphic you want to generate. So if you have many different sidebar widgets in your mock-up, all generated from the same external file, you would only need one data set called 'sidebar_widgets'.

Since we don’t have any previously created data sets, let’s start by creating a new one. To do this, click on the small disk/arrow icon on the left of the trash icon. Now that we have created a new data set, let’s give it a name. Yep, you guessed it. Let’s give it the same name as the variable, layer, and external style-sheet file. As I’ve said before, they should all be the same name.

Data Sets

Do Not Replace

Now that’s done, we can upload the external file. Click on the 'select file' button in the 'Value' section, and choose 'Component_GlobalHeader.psd'. Notice that if you have 'Preview' checked (on the right, under the apply button), you will see the new style sheet appear on your homepage mock-up. Super important: always remember to click 'apply' before clicking on 'OK'. If you do not do this, all that we have gone through would be lost and you would need to redo everything. So remember CLICK 'APPLY', then click 'OK'.

Select File

We have successfully imported the external style sheet into our homepage mock-up! Yay! But wait! We now have this massive layer, but need only part of it.

Homepage Mockup

Step 5 – Masking

Since we don’t want the whole style-sheet to appear in our mock-up, we can basically mask the part we need and hide the rest. We will do this by creating a new shape layer in the same dimensions as the component we want to show. Now to get the shape layer to mask it, all we need to do is drag the mask onto the component layer. You will now see the whole screen filled by the shape layer since we removed its mask. Delete the un-masked shape.

Masking

Step 6 - Updating

Now that you have an external file, let me show you how this is useful. Let’s say that the red selected state on your global header just isn’t working for you and you’d like to switch it to blue. Simple! Go to your original style-sheet 'Component_GlobalHeader.psd' and change the selected color to blue. Save the file and go back to the homepage mock-up. Click on image > apply Data Sets and choose the data set that you would like to update. You will automatically see the change right away.

Updating

Disadvantages

Along with its potential, keep in mind that this is still considered a hack. Until Adobe decides to create a built-in system for importing external PSDs there will never be a foolproof way to do it.

One major disadvantage is that changing a component PSD and saving it will not automatically change it in the mock-ups associated with it. For example, this means that you will always need to 'apply data sets', when opening the homepage mock-up. Though this is something I have not tried, this problem might be able to be solved by creating an action of some sort, making the PSD open and automatically ‘apply data sets’.

Another disadvantage is the folder structure. Moving a file into a new folder tends to mess up the configuration thus creating an error when 'applying data sets'. Since it is random I haven’t found a way to work around it.

With those issues in mind, I still believe that this system saves countless hours of grueling hard labor. You need to know when to use it. Most of the time, it is used only with projects that contain more than 15 to 20 mock-ups.

Conclusion

This example is just the tip of the iceberg. You can see for yourself the amazing potential this system has. Be creative and experiment. Why not try adding sidebar widgets with only one data set?

Opinions expressed in this article are those of the author and not necessarily those of Onextrapixel.