If you want to learn more about Motion UI but have limited time available, our new course, Learn Motion UI From Top to Bottom, is for you.
In just six short videos totalling less than an hour, you’ll learn everything you need to know about Motion UI, the Sass library for transitions and animations from Zurb.
What You’ll Learn
With the help of Envato Tuts+ instructor Adi Purdila, you’ll learn all about creating transitions and animations (and the difference between the two), configuring Motion UI, and integrating WOW.js to reveal elements as users scroll.
By the end of this course you’ll be fully up to speed on Motion UI and ready to use it in your web design projects.
This is just one of a series of “Top to Bottom” courses that Adi has produced lately. You may also be interested in:
You can take our new course straight away with a free 10-day trial of our monthly subscription. If you decide to continue, it costs just $15 a month, and you’ll get access to hundreds of courses, with new ones added every week.
Download New Course: Learn Motion UI From Top to Bottom
Now we understand that Twig—along with the WordPress plugin Timber—can help developers write modular code while developing WordPress themes. With such a modular approach you can handle the logic and the view layer of your web application separately. Let’s jump to slightly more technical stuff: creating Twig templates, converting HTML to Twig files, and how to render the logic or data with twig templates.
Install Timber
First of all, I am going to install Timber, which is a WordPress plugin that helps integrate the Twig templating engine with WP. So, let’s do it.
Let’s begin. I want to display a welcome message at the top of my homepage. How would I go about it without Twig? Probably, I’d include HTML code inside the PHP file and echo the welcome message, as I did in the code example below. My index.php file looks something like this.
<?php
/**
* Homepage
*/
get_header(); ?>
<div> <?php echo "Welcome to my blog!"; ?> </div>
<?php get_footer(); ?>
Now the homepage of my local WordPress install displays a welcome message right at the top. Here’s the screenshot.
Problem
The problem with this approach is that we are mixing data/logic with view. The more complex this file gets, the harder it is to maintain let alone understand—for example, if you add the WordPress loop after this code with a few arguments and then filter and pagination after that. Add to that, PHP inside HTML doesn’t look good when you end up with a bit of the logic.
Modular Approach
To make it more modular, we can think of our content on the homepage in the form of blocks or components. There can be two complete ones by default, i.e. Posts from The_Loop and pagination. Since now we want to add another component at the top, i.e. the welcome message, let’s create a Twig file for that component.
Open a new blank file in the editor and copy paste the following lines of code.
<!-- Welcome Template -->
<section class="welcome_message">
<h2>Welcome to my website!</h2>
</section>
Create a new folder in your theme’s root called viewsand save this file with the .twig extension. For example, I saved the file as welcome.twig.
Rendering the Twig Template
Timber provides us with a few useful functions, one of which is the render function. You can call it like this:
Timber::render();
This function can take up to four arguments. Since that’s out of the scope of this article, you can read about it in the Timber docs. We can pass the name of any Twig file that’s present in the views folder of your theme to this function.
Let’s render the welcome message in the index.php file.
Timber renders the welcome.twig file, loads the HTML and displays the new modified view layer at the front-end like this:
The render() function takes welcome.twig as its argument, but it automatically reads this file as long as the twig templates reside inside the folder named views.
If you want to use a custom name/path for the folder then you’ll have to provide the path of that folder. For example, I created a twig folder in my theme’s root and added it to the render function’s argument.
<?php Timber::render('twig/welcome.twig'); ?>
The Official Load Order
Timber will first look in the child theme and then fall back to the parent theme (same as WordPress logic). The official load order is:
User-defined locations
Directory of calling PHP script (but not theme)
Child theme
Parent theme
Directory of calling PHP script (including the theme)
Item 2 is inserted above others so that if you’re using Timber in a plugin it will use the twig files in the plugin’s directory.
So, now the index.php file has no HTML inside it, and it is rendering a Twig template.
Now let’s send some dynamic data from index.php to the welcome.twig file and render it with Timber.
Sending Data Through Timber to Twig Files
To send data from the PHP file to Twig file, you need to define a context array. The render function takes an array of data to provide Twig templates with some kind of context. Let’s call the array $context, which is an associative array, i.e. it takes up the key-value pairs.
Let’s add a key-value pair that would be a dynamic welcome message, which our PHP file would send to the Twig file.
So, inside the index.php file, I defined an empty $context array at line #8. Then at line #11, I’ve created a variable $var with the value 'Dynamic Message'. At line #14, I have created a key the_message which is equal to $var.
At line #17, I called the render function with the welcome.twig file, but this time, it takes an additional argument, i.e. the $context array. This new argument actually has the data which Timber will send from the PHP file to the Twig file.
So, we defined the context array and added a dynamic message (You can show a different message to different users by adding some kind of logic to it, like displaying the current user’s first name).
Template File
Now we need to use this data, i.e. the_message, in the Twig file. We can echo a variable inside our Twig template by putting double braces around it. For instance, to echo $var in a twig file, we can write {{ var }}. That’s exactly what I did.
The value of the_message will be printed inside the h2 tags. I know, it’s just that simple, and the code looks pretty clean.
That’s it! Save the code and view the dynamic welcome message at the front-end. Here’s the final screenshot.
Conclusion
To summarize, now you can use the PHP file for coding the logic and providing data to a Twig template which contains HTML and renders the Twig variables or functions inside the double braces.
This modular approach can lead to a separate template file for every component in your WordPress theme. Think about having a message.twig component which you could use anywhere in the theme to display any message you want, any number of times.
This was a basic implementation of Twig with Timber. However, in the next two articles I will write about the Timber WordPress Cheatsheet, managing images with Timber, and creating menus without using the crazy walker function.
If you have any questions, post them in the comments below or reach out on Twitter. You can also take a look at my theme code at this GitHub repo.
Download Kick-Start WordPress Development With Twig: Getting Started
Email might seem a little bland and outdated in a world dominated by social media but, when it comes to marketing a business, email still rules. According to a study from McKinsey, email is nearly 40 times more effective for acquiring customers than social media. In fact, during Black Friday sales in the United States, email is the biggest marketing channel to drive sales, accounting for a quarter of all transactions.
Given these stats, it’s easy to see that a strong email marketing campaign can have a significant impact in your business. But, how do you get started with your first campaign, attract your initial subscribers fast, and begin growing your email list?
That’s exactly what we address in this article. Learn strategies on how to build an email list, with pro tips to help you bring in your first 500 subscribers quickly.
If you’re just getting started with building an email list, then you may need an email marketing template to begin with a quality design. We have many professional choices on Envato Market. Now, let’s get into these tips.
1. Optimize Your Opt-in Form Placement
The strategy that will give you the biggest returns with email list building is picking the proper placement and format of your email opt-in forms.
But before you get to picking your opt-in form placement, it’s best to declutter your site. By removing unnecessary elements from your site design, your visitors can focus better on your calls-to-action and find the content they are after. Basecamp, a project management software company, found that by decluttering their homepage, they saw an increase in conversions, leading to 14% more visitors to their sign-up page.
When it comes to form placement, however, most businesses have multiple opt-in forms, often found in the following places:
Keep in mind that placing opt-in forms in these sections isn’t a “set it and forget it” type of deal. Using site analytics tools, you’ll get feedback on which forms work best over time. You’ll also be able to test which email subject headlines, offers, and calls-to-action convert more of your visitors into subscribers. Still, just by setting up your forms in the best places to capture emails, you’re already starting on the right foot.
2. Offer Something Your Readers Can’t Resist
Once your audience can actually find your opt-in forms in the right places, what can you do to make sure they sign up? You’ll have to create an attractive offer that they wouldn’t want to miss.
According to a survey conducted by Ascend2, a marketing research firm, the most effective tactics that marketers use for growing their email list is to provide subscribers with access to restricted areas of a website or access to content downloads.
With these survey results in mind, it’s best to offer potential subscribers access to exclusive content. If you’ve ever subscribed to email newsletters yourself, you’ll notice that some common offers come in the form of ebooks, whitepapers, reports, or tutorials. While this exclusive content usually comes as downloadable PDFs, some of them can be in video or audio format.
But any kind of bonus content won’t do. It has to be something that your target subscribers wouldn’t want to miss out on. Understand how they think and what their needs are, then tap into these needs when you create your offer.
It also helps if your subscription offer can be considered “premium content” — of a higher quality than most of the readily available content on your website. For example, if it’s an ebook, make sure it’s longer and more comprehensive than your blog posts. Or, if it’s a weekly email newsletter subscription, you could re-frame it as free weekly lessons on your topic.
It’s this exclusive, premium element that will make your readers want to take the extra step of subscribing to your email list rather than just regularly returning to your site. Another term for this premium content is a buzz piece. Learn more about how creating premium content helps you with building an email list:
Social media can be an excellent way to reach out to your audience, especially if they haven’t discovered your website yet or haven’t subscribed to your mailing list. However, according to the same Ascend2 survey, marketers find that social media sharing is the most difficult tactic they use to build their email list.
This is no surprise since demographics, user behavior, and marketing strategies tend to vary depending on the social network you’re using. Given the difficulty of implementing a comprehensive social media strategy, it’s best to focus on just one network when planning to grow your email list via social media.
Pick the social media site that your target audience is most likely to use and promote your mailing list there. This means that you should be aware of a social media site’s demographics. For example, LinkedIn is used by professionals from 25 to 44 years old, while Snapchat is typically used by people under 25 years old.
It will also help to take note of any site-specific features you can take advantage of. Facebook Pages will allow you to add a specific call to action on your pages. You can use this button to direct visitors from your Facebook Page to your email signup forms.
Alternatively, there are apps that will allow users to get access to your exclusive content by “paying” with a Tweet or Facebook Share. You can then redirect these users to subscribe to your mailing list after they’ve shared the exclusive content you’ve promised. This approach means that your new subscribers also get to share your content to other potential subscribers, broadening your reach.
Another email list building tactic you could use is to take advantage of the content on your site that generates the most amount of traffic. Find your website’s most popular pages or blog posts and create a more prominent email capture form in those pages.
This works better if you can create specific offers that are relevant to each post, so that visitors who are already reading about a topic are given the option to dig more into it.
Brian Dean, the founder of digital marketing blog Backlinko, found that this simple tactic gave him a 785% increase in opt-in conversions. These new opt-in forms also accounted for 30% of all of his new subscribers. By pairing your already-popular content with an additional downloadable resource, you can attract more subscribers.
5. Hold Contests
If you want to generate more interest in your brand—and therefore bringing more visitors to your site and email opt-in forms—holding contests is a great way to attract attention. In exchange for a chance to win a prize, your website visitors have to send in their email address and subscribe to your newsletter. This is the tactic that blogger Rob Young used to attract 500 additional subscribers to his list. You can also use social contests to grow your email list.
But contests aren’t just great for attracting new subscribers. A case study from Marketing Sherpa also found that contests can also reignite the interest of inactive subscribers, with contest emails generating a 20% open rate among inactive subscribers. Though active subscribers had a higher email open rate at 60%, it’s still good to see your more stagnant followers interact with your business again.
6. Host a Webinar
If you’ve ever attended a webinar, you’d know that submitting your email address is a crucial part of the process. Email opt-ins help webinar attendees access the webinar, get reminders before it starts, and receive additional post-webinar content such as recordings, PowerPoint presentation decks, or the presentation text. As an entrepreneur, you can be on the other side of the screen and create your own webinar—and capture email addresses along the way.
One disadvantage to this approach is that hosting webinars can be a lot of work. Apart from planning the presentation, you’ll have to promote the webinar, plan for all the hardware and software you’ll use, present your webinar live, and perhaps answer viewer questions in real-time. With proper planning, however, you can repeat or automatically replay your next webinars, as well as repurpose your webinar’s content over time.
7. Guest Post on Popular Blogs
It might seem like an impossible task to gather your first few hundred subscribers if you have a small audience to begin with. If this is the case with your attempts at growing your email list, why not tap into the audiences of websites and businesses that are more popular than yours?
This is where guest blogging comes in. Through guest blogging, you can submit informative, engaging articles to popular blogs and redirect at least a fraction of their audience back to your site. It’s through strategic guest posting that Bryan Harris, a business coach, attracted 323 new email subscribers within the first 3 days of publishing his guest post.
To get started guest posting, look for the most popular blogs in your niche and study them. See if there are articles you can contribute that will be a good fit for their site. Then pitch your guest post article idea professionally. Of course, make sure that any article you submit can redirect the reader’s attention to your own email newsletter in the process.
Keep Optimizing
After your email list reaches 500 subscribers, it’s time to step back and optimize. Review the tactics you’ve done so far and keep doing what works, as well as testing different types of forms and offers to see if you can get your conversion rates a little higher.
Also, as you send more emails to your list, you’ll get to know your subscribers’ activity. This will take you a step further and will help you learn how to keep them on your list, how to come up with emails they’ll actually read and open, and what it takes to turn these active subscribers into actual revenue for your business.
Also, grab an email marketing template from Envato Market, so your emails look professional, and your new subscribers connect the quality of your email designs with your business message.
Download How to Build an Email List: Get Your First 500 Subscribers Fast
Almost exactly two years ago we published our first translation; a step into the unknown, a risk perhaps, but something we felt sure our community would be enthusiastic about. Fast forward to today and we’ve published over 2,000 translations, ranging across 41 different languages, submitted by almost 600 dedicated volunteers. These posts see around a quarter of a million monthly pageviews and are helping us build upon our strong global community.
Thank You!
2,000 is a very significant milestone–thank you, community members. You rock! I should also thank translation platform Native, without which we’d still be wrestling with text files and email.
So which translations and which languages have fared best on Envato Tuts+ Web Design over the last two years?
Right from the start we knew that our Spanish translations would do well; the Hispanic community across Envato has always been large, and as one of the most widely spoken languages in the world it’s no surprise that Spanish has been supremely active at Envato Tuts+. To date, we have around 150 web design tutorials in Spanish, and 10 of the 25 most visited web design translations are Spanish.
Henri has published 54 translations across the network, giving each one a boost by promoting it on his blog. His translations have given our tutorials a real presence in France, but most significantly (in my opinion) across French speaking nations in Africa.
Here are the top three most productive translators for this topic:
We’ve built a great foundation for a truly global educational platform. Thanks to this solid start we’re reaching more people than ever, helping them learn and understand creative subjects.
We’d like to continue this growth, especially in less prominent languages. If you can help, please volunteer by clicking the Translate this post button in the sidebar of a tutorial which interests you! Read more about what this entails by going to Translate for Envato Tuts+.
Help us spread the word by sharing translations on social media, and sign up to our newsletter to stay up to date.
If you’d specifically like to hear about our progress in China, talk to Kendra; our feet on the ground in Beijing. Kendra is working to build our community in China, talking with translators and instructors, and managing Chinese social media. Get in touch via Twitter @kendraschaefer, or through WeChat at kendrakai.
p5.js is a JavaScript library for artists, designers, and educators, with a specific focus on the visual arts. It’s an extremely easy way for you to create interactive pieces of art, animations and prototypes in the browser.
It is heavily inspired by the programming language Processing, which refers to itself as a “flexible software sketchbook”. Processing was created in 2001 with the purpose of teaching non-programmers how to code, but since then it has become the language of choice for tens of thousands of artists, designers and students.
p5.js, however, has a slightly different aim in mind. p5 brings the power and simplicity of Processing to the web. This tutorial will show you how to create your first p5 “sketch” and some fun things you can do with it.
Getting Started
Because p5 is designed for the web, we’re going to need a webpage. Make a new directory on your computer and create an index.html file inside it. We don’t need much in here, just the standard bits and bobs.
Next, we’ll need the p5 library itself, which we can easily get from the p5 download page. We only need the basic library, so just download the single file version of p5.
Put the downloaded file in the same directory as your HTML file. We can then reference it in our HTML like so:
We’ll also need a JavaScript file for our sketch. A sketch is Processing speak for the drawing or animation we create with p5. Make another file, again in the same directory, and call it my-first-sketch.js. This needs to be referenced after the p5 library so our script knows all the methods provided by p5.
That’s all the setup there is! We’re now ready to start creating our masterpiece.
Core Concepts
p5 gives us two methods that are essential when creating a sketch: setup() and draw(). You can probably guess what each of them are for, but they have an important hidden difference. Open up my-first-sketch.js and add the following:
// Setup code
function setup () {
console.log('Hi from setup!');
}
// Drawing code
function draw () {
console.log('Hi from draw!');
}
Now even though we have just defined these functions and done nothing else, because p5 was expecting us to do this, it is automatically going to execute them when we load the page. Open your index.html in your favourite browser and open the JavaScript console. Here’s what I see:
As you can see, both functions were called automatically, but the setup() function was called only once, while draw() was called over and over again—768 times within a few seconds! We’ll see the importance of this a little later.
OK, to begin drawing, we’ll require something that all artists need: a canvas. All we need to do is use p5’s createCanvas() function and give it a width and height as arguments. Where should we call this function from? setup() of course.
function setup () {
// Create a canvas 200px wide and 200px tall
createCanvas(200, 200);
}
If you refresh your page, you’ll see nothing different. This is because the canvas is transparent by default. Let’s spruce it up with a bit of colour. How about a nice red? Stick this line into setup() as well.
background('red');
p5 is clever enough to know whether we’ve used an HTML colour name or a hex value, meaning background('#FF0000'); is equally valid.
Shapes
Let’s get drawing. We have a few built-in shapes at our disposal. Let’s start with a basic rectangle. In our draw function, we can write the following. Remember, all coordinates start at (0, 0), which is the top-left corner of the canvas.
function draw () {
rect(0, 0, 50, 50);
}
If you refresh your page, you should see this: a rectangle that starts at (0, 0) and is 50 px wide and 50 px tall (a square).
This square can be coloured in as easily as our background. All we have to do is specify a fill colour before we draw the rectangle. Let’s use some hex this time.
fill('#CC00FF');
rect(0, 0, 50, 50);
Now we have a purple square. Not exactly a masterpiece, but we’re getting somewhere. How about another shape? A circle, I hear you say? No problem.
// Draw an ellipse that's 25px from the top and
// 25px from the left of the edge of the canvas.
// The ellipse is 25px tall and 25px wide making
// it a circle.
ellipse(25, 25, 25, 25);
You’ll notice that our circle has not only been drawn on top of our rectangle, but it’s also the same colour as the rectangle.
This is because the order in which we call these functions is extremely important. If we had drawn the rectangle after the ellipse, we wouldn’t see the circle at all as it would have been painted over. As for the circle’s fill colour, it’s the same as the square because any shape drawn after the fill() function is called will use that colour. To change the colour of the circle, simply call the fill colour again with a different value.
fill('#66CC66');
ellipse(25, 25, 25, 25);
We now have this:
Hmm, still not that exciting. Let’s see what we can do. Now, remember the majority of our code here is contained within the draw() function, and as we saw before, anything in the draw function gets called over and over again. So essentially our square and circle are being drawn over and over again on top of the square and circle that were drawn in the previous call of the draw function.
What if we were to draw our shapes in a different place each time?
Different Time, Different Place
In order to draw your shapes in a different place, you may be tempted to change their coordinate values. This is perfectly acceptable and a great way to have complete control over your drawing.
There is also an alternative. We can change the offset of the entire canvas, meaning that we can change the origin, the top-left coordinates (0, 0) to something else. The outcome of this is that our shapes are drawn with this offset. If we were to write translate(10, 10); we’d end up with this.
Note that our shapes are now drawn 10 px from the left and 10 px from the top.
This hasn’t really fixed our original problem of the shapes being drawn over each other repeatedly, but what if we were to change the origin of the canvas with each draw() call? The shapes would be drawn in a different position each time. But what position? And how would we come up with a different one each time draw() is called? Luckily, p5 has us covered with the random() function—an easy way to generate a random number. We’ll use this to randomly change the offset of our canvas.
function draw () {
// Offset the canvas
// random(0, width) returns a value between
// 0 and the width of the canvas.
// As does random(0, height) for height.
translate(random(0, width), random(0, height));
// Existing code here
}
This gives us an animated version of this:
Whee! You may find this animation a bit fast. This is because p5 is drawing our shapes as fast as it can, with draw() being called again and again. If you want to slow this down a bit, you can change the frame rate to reduce the frequency in which draw() is called. Put a call to frameRate() in your setup function.
function setup () {
createCanvas(200, 200);
background('red');
frameRate(5);
}
That’s better. Again it’s a bit boring with the square and circle always being on top of each other. Let’s try rotating our shapes to make things more interesting. So, how do we do that? Yup, you guess it, p5 has us covered yet again. First we tell p5 we want to rotate using degrees instead of radians, and that we want to rotate randomly before we draw each shape.
angleMode(DEGREES); // uses global DEGREES constant
rotate(random(1, 360)); // rotate to random angle
fill('#CC00FF');
rect(0, 0, 50, 50);
rotate(random(1, 360));
fill('#66CC66');
ellipse(25, 25, 25, 25);
We’ve created a monster.
I’m pretty sure I had a shirt back in 1991 with this same pattern on it…
No, my mistake, it had some yellow triangles on it. Let’s go all in and add some.
// Random positioned yellow triangle
rotate(random(1, 360));
fill('yellow');
// 3 pairs of triangle points
triangle(25, 0, 50, 50, 0, 50);
Lovely. Bad 90s shirt or modern-day Jackson Pollock? That’s up to you. Art is in the eye of the beholder, as they say.
Summary
I hope you’ve seen from this tutorial how easy it is to start drawing in the browser with p5.js. p5 has many more helpful, convenient methods to help us draw shapes, animate and handle user input. If you’re interested in learning more, visit the p5 reference page, or check out my Envato Tuts+ course Interactive Art With p5.js.
For reference, here’s the complete source for our p5 sketch:
In
this tutorial you will learn how to create a cupcake icon in Adobe
Illustrator, and starting from the first one, you’ll create other
delicious variations just by making a few changes.
Let’s
take advantage of the overhead
view of these icons and be as creative as possible with the
decorations. The four flavors that I’ve chosen are vanilla confetti,
red velvet, chocolate almond, and blueberry cream. Let’s begin!
Launch Illustrator and
go to File
> New to
open a blank document. Type a name for your file, set up the
dimensions, and then select Pixels as Units and RGB as Color
Mode.
Make sure that Align
New Objects to Pixel Grid is
not checked.
Next,
go to Edit
> Preferences > General and
set the Keyboard
Increment to 1
px,and
while there, go to Units to
make sure they are set as in the following image. I usually work with
these settings, and they will help you throughout the drawing process.
2. Create
the Paper Cup
Step
1
Start
by drawing a 190 x 190 px circle on your artboard with the Ellipse
Tool (L). With the shape still selected, go to Effect > Distort &
Transform > Zig Zag and apply the settings shown.
Step
2
With
the circle still selected, choose Expand Appearance from the Object
menu and Ungroup (Shift-Control-G) if necessary. Fill the resulting
shape with the linear gradient shown at a -45 degrees Angle. Let’s
name this shape “paper exterior”.
Step
3
While
“paper exterior” stays selected, go to Object > Path >
Offset Path and apply a -3 px Offset. Fill the smaller shape with the
radial gradient shown and name it “paper interior”.
Group
(Control-G) these two shapes and name the group “paper cup”.
3. Create
the Cupcake
Step
1
Use Ellipse Tool (L) to draw a 170 x 170 px circle and arrange it in the
center. Fill it with the radial gradient shown and name the shape
“cupcake”.
Step
2
While
“cupcake” stays selected, take a look at the Appearance panel.
Add a New Fill above the first and keep the same gradient. Go to Effect > Texture > Texturizer, apply the settings shown, and hit OK. Reduce the Opacity to 33%.
4. Create
the Vanilla Icing
Step
1
Draw
a shape like below and fill it with yellow (1). Copy and Paste in
Back (Control-B) this shape, change the fill color to warm brown, and
then move it a little down and to the right to act as the shadow (2). Copy and Paste in Front (Control-F) the first shape, make it smaller, and change the fill color (3).
Step
2
Grab
the Pen Tool (P) or the Pencil Tool (N) and draw a spiral in the
center (1). Stroke it with the Charcoal – Rough Art Brush from the Brush Libraries Menu > Artistic > Artistic_ChalkCharcoalPencil.
Select yellow as the stroke color and set the Weight to 2 pt (2).
Next, go to Effect > Stylize > Feather and apply a Radius of 5
px (3).
Step
3
Copy
and Paste in Front (Control-F) the spiral from the previous step,
change the stroke color to brown, and set the Weight to 0.5 pt. The
rest of the settings remain the same.
Step
4
Draw
a new spiral in the middle but smaller. Use the Charcoal – Rough
Art Brush again to stroke it and keep the Weight at 1 pt. Apply a 5
px Feather Radius.
5. Decorate
With Confetti Sprinkles and Cherry
Step
1
To
create the confetti, just take the Ellipse Tool (L) and draw as many
small circles as you like. Fill them with various colors, and after
that Group (Control-G) all of them. With the group still selected, go
to Effect > Stylize > Drop Shadow and apply the settings shown.
Step
2
For
the cherry, start with a 50 x 50 px circle. Fill it with the radial
gradient shown below.
Step
3
Draw
a small shape on the upper left side using the Pen Tool (P). Fill it
with the linear gradient shown; then go to Effect > Blur >
Gaussian Blur and apply a Radius of 2 px.
Step
4
Draw
another small shape in the bottom right side and fill it with the
linear gradient shown. After that, apply a 2 px Gaussian Blur.
Step
5
Group
(Control-G) all the shapes that compose the cherry and move them onto the icing. Draw a new circle about the size of the cherry, fill it
with the radial gradient shown, and then set to Blending Mode
Multiply. This shape will act as the shadow and should be behind the
cherry.
At this point, the Vanilla Confetti Cupcake is ready.
6. Create
the Red Velvet Cupcake
Step
1
Now,
we are going to transform the vanilla cupcake into a red velvet
cupcake. First, make a copy of the vanilla cupcake, but delete the
confetti and the cherry because you don’t need them.
Step
2
For
visual purposes and to focus better on the changes that you need to
make, I’ve hidden the icing group, but you don’t have to.
First,
select “paper exterior” and change the fill gradient, and after
that change the fill color for “paper interior”.
Step
3
Select
“cupcake”, and in the Appearance panel, change the two existing
gradients to the one shown below. Increase the Opacity to 44%.
Step
4
Change
the fill colors of the three shapes that compose the icing, and after
that change the stroke colors of the three spirals. The rest of the
settings remain the same.
Step
5
Use
the Pen Tool (P) to draw a random but very small shape and fill it
with red. Don’t draw a circle because in the end, the red crumbs on
the icing will look too perfect and regular. Drag this shape into the Brushes panel and choose New Scatter Brush.
Now,
grab the Pen Tool (P) and draw a messy spiral on the icing, and use
the Scatter Brush that you just saved to stroke it. Keep the Weight
at 1 pt but open the Stroke Options window (double click on the
Stroke attribute in the Appearance panel) and change the settings as
indicated.
Step
6
While
the messy spiral stays selected, go to the Object menu and choose Expand
Appearance. As a result, the stroked path will turn into a group of
red crumbs. Take the Selection Tool (V) and double click on this
group to enter the Isolation Mode.
Now, you’ll be able to select the
crumbs individually and delete the ones that are scattered too far
away. To Exit Isolation Mode, press the arrow in the corner twice.
At this point, the Red Velvet Cupcake is ready.
7. Create
the Chocolate and Almonds Cupcake
Step
1
Now,
let’s transform the red velvet cupcake into a chocolate cupcake.
First, make a copy of the red velvet cupcake, but delete the red
crumbs.
Step
2
The
paper cup remains the same. Select “cupcake” and change the two
gradients in the Appearance panel.
Step
3
Change
the fill colors of the three shapes that compose the icing, and after
that, change the stroke colors of the three spirals as indicated. I
also made a copy of the smaller spiral and moved it to the top.
Step
4
Draw
an oval shape with the Pen Tool (P) similar to an almond slice. Make
a few copies and arrange them over the chocolate icing. Use the two
gradients to fill them.
Step
5
Apply
the Drop Shadow effect to each almond slice in order to add a small
shadow. You can’t really apply the same settings to all of them
because that depends on the position of the almonds, but in the next
image, you can see two examples.
At this point, the Chocolate and
Almonds Cupcake is ready.
8. Create
the Blueberry and Cream Cupcake
Step
1
Now,
let’s transform the vanilla cupcake into a blueberry cupcake. First,
make a copy of the vanilla cupcake, but delete the confetti and the
cherry.
Step
2
The
paper cup and the cupcake remain the same. Change the fill colors of
the three shapes that compose the icing, and after that, change the stroke
colors of the three spirals.
Step
3
Go
to the red velvet cupcake, select only two out of the three shapes
that compose the icing, and make a copy. Group (Control-G) the two
shapes, make them smaller, and arrange them over the blueberry icing.
Step
4
Now,
make a copy of the cherry, and let’s transform it into a blueberry.
First, select the circle and change the gradient fill. After that,
change the fill colors of the two highlight shapes. The Gaussian Blur
effect remains the same.
Step
5
Move
the blueberry on the icing. Draw a new circle about the size of the
blueberry and fill it with the radial gradient shown. Set the Blending Mode to Multiply. This shape will act as the shadow and
should be behind the blueberry.
At this point, the Blueberry Cream Cupcake
is ready.
9. Add the Shadows
Step
1
Select the “paper cup” group, go to Effect > Stylize > Drop Shadow, and apply the
settings shown.
Step
2
Repeat
the previous step for the other three cupcakes. Apply the Drop Shadow
effect to each “paper cup”.
Congratulations,
You’re Done!
Challenge
your creativity and use these cupcakes as a starting point to create
other delicious flavors, or decorate them in a different way. If you
do, don’t forget to share your re-creations with us. I would love to
eat them…. oops! I mean, to see them!
Download How to Create Delicious Cupcake Icons in Adobe Illustrator
One of the most significant changes to Android design was introduced during the 2014 Google I/O conference, material design. Even though Google had introduced a set of guidelines for their new design philosophy, developers were responsible for implementing the new patterns from scratch.
This led to many third party libraries that achieved the goals of material design with similar, but different, implementations. To help alleviate some of the development pain of material design, Google introduced the Design support library during the keynote of the 2015 Google I/O conference.
As with many things in software development, the Design support library improved with time, adding support for bottom sheets with the 23.2 release. In this article, you learn how to easily implement the bottom sheet pattern into your own apps. A sample project for this article can be found on GitHub.
1. Setting Up a Bottom Sheet
To implement the bottom sheet, you have two options, a container view with a BottomSheetBehavior in the layout file or a BottomSheetDialogFragment. To use either, you need to import the Design support library into your project, with a minimum version of 23.2. You can do this in build.gradle by including the following line under dependencies:
compile 'com.android.support:design:23.2.0'
Once you have synced your project with the Design support library, you can open the layout file that needs to include a bottom sheet. In our sample project, I use the following XML, which displays three buttons in activity_main.xml.
There are a few key points within the layout file that you need to be aware of. To use the bottom sheets widget, you must use a CoordinatorLayout container for the views. Towards the bottom of the file, you notice that there is a NestedScrollView containing a TextView. While any container view can be used in a bottom sheet, scrolling can only properly occur if you use a container that supports nested scrolling, such as the NestedScrollView or a RecyclerView.
For a container to be recognized by the Design support library as a bottom sheet container, you need to include the layout_behavior attribute and give it a value of android.support.design.widget.BottomSheetBehavior. You can see this used above in the NestedScrollView.
Another key attribute to notice for the bottom sheet container is the layout_height. Whatever dimensions your container item uses, controls how your bottom sheet is displayed. There is one caveat to be aware of with the bottom sheet height. If you use the CoordinatorLayout, to move other View objects around, such as with a CollapsingToolbarLayout, then the height of your bottom sheet changes. This can cause an undesirable jumping effect.
2. Showing a Layout Based Bottom Sheet
Once you have added a view container and properly set it up within your layout file, you can open the Activity or Fragment that uses the bottom sheet. In the sample project, this is MainActivity.java.
For your bottom sheet to be displayable, you need to create a BottomSheetBehavior. This is created by getting a reference to the container view and calling BottomSheetBehavior.from() on that container. For this sample, you also reference the three buttons from the layout and call setOnClickListener() on them.
Now that you have created a BottomSheetBehavior, the last thing you need to do is show your bottom sheet View. You can do this by setting the state of your BottomSheetBehavior to STATE_EXPANDED, which we do in the sample app when the top Button is clicked.
@Override
public void onClick(View v) {
switch( v.getId() ) {
case R.id.button_1: {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
break;
}
}
}
When this is done, your app should look like this:
To hide the bottom sheet, the user can swipe it down to hide it from the screen or you can set the BottomSheetBehavior to STATE_COLLAPSED.
3. Peeking a Bottom Sheet
You may have noticed in various Android apps and widgets from Google, such as the Place Picker from the Places API, that the bottom sheet pattern is used to display a preview of the bottom sheet that can be expanded for more details. This can be achieved with the Design support library bottom sheet by setting the collapsed size of the View with the setPeekHeight() method. If you want to show the shorter version of the bottom sheet, you can set the BottomSheetBehavior to STATE_COLLAPSED.
When the middle button is clicked, you end up with a bottom sheet in peek mode that can be expanded to its full height by dragging it up.
You may notice that when you attempt to drag the bottom sheet down, it only collapses down to its peek size. You can solve this by adding a BottomSheetCallback to the BottomSheetBehavior, setting the peek size to zero when the user collapses the sheet. In the example app, this is added at the end of onCreate().
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
mBottomSheetBehavior.setPeekHeight(0);
}
}
@Override
public void onSlide(View bottomSheet, float slideOffset) {
}
});
4. Using a Bottom Sheet Fragment
As I mentioned earlier in this article, you can also display a BottomSheetDialogFragment in place of a View in the bottom sheet. To do this, you first need to create a new class that extends BottomSheetDialogFragment.
Within the setupDialog() method, you can inflate a new layout file and retrieve the BottomSheetBehavior of the container view in your Activity. Once you have the behavior, you can create and associate a BottomSheetCallback with it to dismiss the Fragment when the sheet is hidden.
public class TutsPlusBottomSheetDialogFragment extends BottomSheetDialogFragment {
private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
};
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.fragment_bottom_sheet, null);
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if( behavior != null && behavior instanceof BottomSheetBehavior ) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
}
}
Finally, you can call show() on an instance of your Fragment to display it in the bottom sheet.
BottomSheetDialogFragment bottomSheetDialogFragment = new TutsPlusBottomSheetDialogFragment();
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
Conclusion
Using the Design support library to display a bottom sheet is both versatile and simple. They can be used to display details or pickers without getting in the way, as well as act as a great replacement for the DialogFragment in the proper situation. Understanding how the bottom sheet can be used in your app will give you an additional tool to make great apps.
Download How to Use Bottom Sheets With the Design Support Library
Managing your finances can be one of the hardest parts of running your own business. Our new Coffee Break Course, A Freelancer’s Quick Guide to Finances, is designed to help you manage the key financial elements of your business.
In this ten-minute video course, Paul Boag, founder of UK web design agency Headscape, will introduce you to five figures that you should be tracking in your business.
Watch the introduction below to find out more about the course.
You can take our new Coffee Break Course straight away with a free 10-day trial of our monthly subscription. If you decide to continue, it costs just $15 a month, and you’ll get access to hundreds of courses, with new ones added every week.
Download New Course: A Freelancer’s Quick Guide to Finances
Fastlane is a tool that every serious iOS developer should know. It was created out of the pain that came from interacting with iTunes Connect in its early days. Although the iTunes Connect interface has become much better, fastlane still has a lot to offer by automating and easing the process of interacting with the Developer Portal and iTunes Connect.
Envato Tuts+ instructor Markus Mühlberger has created a couple of Coffee Break Courses to help you learn fastlane. Each course is just ten minutes long and covers a single aspect of the tool. Here are more details.
In this course, you’ll learn how to use fastlane to screenshot and submit your iOS app from the command line. After watching this course, you should be able to create automated workflows for adding your app to the iTunes Store, including metadata, binaries, and bundled screenshots in many different languages and screen sizes.
Find out how to use fastlane to sign and provision your iOS app from the command line. After watching this course, you should be able to create automated workflows to create signing certificates and provisioning profiles. You’ll also learn how to manage these certificates and profiles in a team environment.
If you’re ready to move your app development into the fastlane, you can take our Coffee Break Courses straight away with a free 10-day trial of our monthly subscription. If you decide to continue, it costs just $15 a month, and you’ll get access to hundreds of courses, with new ones added every week.
If you want to improve as an iOS developer, you could also check out the hundreds of useful iOS app templates on Envato Market.
Download Learn About Fastlane in Our Coffee Break Courses
Keynote for Mac makes it easy to make and present beautiful presentations. In this article, we cover the basics of Keynote, as well as how you can improve your Keynote skills. Learn how to get up and running with Keynote and get your presentation started.
What is Keynote?
If you’re unfamiliar with Keynote, then let’s first take a quick look at what it is and why it’s such a useful tool.
Keynote is slideshow presentation software developed by Apple. You can use it to create a well-designed presentation with. Here are a few of the features that are packed into Keynote:
Simplicity in design, so you can make a presentation more easily.
Packed with powerful features you need to craft a quality presentation.
Easy?to?use visual tools, such as drag-and-drop functions.
Animation options to add subtle effects and cinema?quality transitions.
Device synchronization, to move from your Mac to iPhone or iPad and vice versa.
Impressive charts, from column, bar, pie, scatter, bubble charts, and more.
To give you some ideas how Keynote is being used, here are examples of use cases:
I need to present a new product to my audience.
I need to create a sales deck I can send to people.
I need to follow our company design guidelines and use their Keynote template to create my reports.
I’m giving a talk and want to display visuals to support my story.
The possibilities are endless. As long as a slideshow is involved and you’re working on a Mac device, often Keynote is the ideal tool to get the job done. Also, on a modern Mac device, Keynote comes free of charge. If not, you can purchase Keynote directly from the App Store.
Comparing Keynote Vs. Powerpoint
Why Use Keynote Instead of PowerPoint?
Most of us who have worked with a Windows device at some point are familiar with PowerPoint. PowerPoint is known for creating slideshow presentations and is supported both on Windows and Mac. Keynote has a few tricks up its sleeve that make it a viable alternative to PowerPoint. Noticeable is its simplicity of use and easy cross-device compatibility.
Apple prides itself in only showing relevant tools based on what you’ve selected in the user interface. This makes working in Keynote feel more intuitive, but for power users PowerPoint packs more features.
Powerpoint does offer more advanced functionality than Keynote. For example, the ability to merge shapes in Powerpoint makes it more powerful if you want to customize your slides to the tiniest of details. Using charts in Keynote is incredible simple, while in Powerpoint it’s more complex but with a lot more flexibility.
To have an elegant presentation up and running very quickly, Keynote is still the clear winner. Apple’s ready-made templates are gorgeous and assure you can focus on the content instead of the design of your slides.
Bottom line:
Use Keynote because its packed with intuitive design tools and is built into your Mac devices.
Also, use Keynote because its easier to work with to create a quality presentation quickly.
Use PowerPoint if you’re an advanced power user that needs more robust functionality and the learning curve is worth investing your time in.
Here is a Tuts+ article that outlines additional Keynote advantages:
Another point to consider is compatibility between Keynote and PowerPoint. Keynote files can readily be ported over to PowerPoint. You can save a Keynote file as a PowerPoint doc. Or you can edit PowerPoint documents right in Keynote. So, you’re not locked in by choosing to work with Keynote or PowerPoint in any case.
Keynote and iCloud
Keynote, as part of the iWork software suite, is supported by iCloud. iCloud offers you the ability to save your Keynote files online, which then can be accessed from any device. While you’re working on a Keynote file saved in iCloud, it synchronizes automatically.
iCloud offers the ability to collaborate online on a Keynote file as well, directly from your browser. You can access Keynote in iCloud by surfing to the iCloud website.
Keynote Basics: Getting Up and Running
Let’s cover the basic functionalities of Keynote, in order to understand how Keynote can be used.
1. Creating Slides
Everything you do in Keynote always starts from slides. A slide, in essence, is your working canvas. You can add text, media, charts, and more on your slides to display the content you want to present.
You can add a slide easily by clicking the Add Slide button in the Keynote toolbar. You notice a new menu appearing, giving you the option to choose between different master slides. A master slide is a slide template.
You can easily create master slides yourself, as explained in a tutorial covering how you make Keynote presentation templates.
2. Working With Media
You can add media to your slides, including photos, music and movies. The easiest way to do this is to drag the file you would like to use in your slide directly into Keynote. Then, using the Format tab, located on the right in Keynote, you can format the media as you please.
If you’re using a master slide, dragging media on top of a placeholder will format the media automatically.
3. Text, Shapes and More
Besides the use of visual assets, you can add text, charts, tables and shapes. You can add this type of content, by selecting one of the options in the Keynote toolbar. You can choose what type of table, shape or chart you would like to use.
When you select an element in Keynote, on the right you can see the Format tab. Here, you can tweak the formatting of your selected element, whether it is text, media or something else.
For text for example, you can tweak the font size and the font color. For a table, you can change the colors of the table or edit the typography.
Finally, there’s also the Comment feature. You can use comments to collaborate on a document, or write helpful reminders for yourself while you’re working on a Keynote file. These are not displayed during a presentation.
If you want to write reminders you’d like to see while you’re presenting you can use presenter notes. To access presenter notes, in the Keynote toolbar click the view button located upper left. Then, click on show presenter notes. Directly under a slide, a white note area pops up. You can use this section to write presenter notes, which are visible to you while giving a presentation. The notes which you write are specific for each slide.
4. Keynote Animation
A different tab on the right is the Animate tab. Here, you can handle different types of animations. There are two different animations to keep in mind:
Slide animations
Element animations
When you click on a slide in the slide overview menu on your left, any animation you’ll add will affect the transition between slides.
While if you click an element in your slide, it will affect the animation of the element in your slide. For example, you can do this to animate a chart in the slide.
Keynote Tutorials and Resources
Below are tutorials and resources to help you master the basics of Keynote: create a great presentation, work with professional designs, and present to your audience.
1. Keynote Basics
First here is a tutorial that walks you through all the basics of creating a Keynote presentation. It will walk you through each step of creating your first presentation:
A useful feature to save a lot of time in Keynote is to use templates. Templates can be used to quickly put a beautiful presentation together, by only changing the content of the presentation and sticking to the design of the presentation.
Keynote comes with a number basic templates to start working with. You can also use the templates other people have created in Keynote to have a beautiful presentation with little work. They come with a professional options already build in.
We have a number of professional Keynote templates on our GraphicRiver marketplace, if you’re interested in working with a professional design. Browse through them and purchase one at an affordable price. Also, here are some useful related links:
Creating a Keynote presentation is half the battle. Giving a presentation can be just as challenging. To help you become a better presenter, below are some useful resources to get you started.
Be sure to relax and focus on your key messages. Preparing your presentation and practicing goes a long way to improve your presentation skills.
Keynote From Beginner to Beyond
Learning the basics of Keynote is simple. The intuitive interface and elegant design tools make sure you can create a presentation rapidly.
Mastering Keynote is a bit trickier. There’s a lot you can do with Keynote. Using sequences of different animations for example, or even going so far to use Keynote as the tool to prototype design interfaces.
But, without a doubt, as a Mac user having basic knowledge of Keynote is useful on many occasions.
Throughout this series, we’ve looked at a number of the metadata APIs that are offered by WordPress. This includes the Post Meta API and the User Meta API. Today, we’re going to be rounding out the series by looking at the WordPress Comment Meta API.
Note that this is that the final metadata API WordPress offers. As of WordPress 4.4, there’s now a Term Metadata API. In order to fully understand it, it’s important to understand taxonomies, terms, and their relationships within the context of WordPress. In an upcoming series, I’ll be covering exactly that.
But today, we’re going to be focused on managing metadata associated with comments. If you’ve not read anything else in this series up to this point, I recommend reviewing what we’ve covered thus far.
If you’re all caught up, then let’s get started.
The WordPress Comment Meta API
Throughout this series, we’ve been using the WordPress definition of metadata as our foundation for understanding how this information is represented in the context of our environment.
Meta-data is handled with key/value pairs. The key is the name of the meta-data element. The value is the information that will appear in the meta-data list on each individual post that the information is associated with.
In keeping consistent with the rest of the content that we’ve seen throughout this series, this definition holds true with comment metadata just as it did with post metadata and user metadata.
The upside to this is that once you’ve gotten a handle on the various metadata APIs that we’ve covered, there should be very little surprise with how other metadata functionality works. There may be a few things different depending on which API you’re using, but the gist of the functionality will be the same.
And, as you will see, this continues to be the case with the comment metadata API.
Working With the Comment Metadata API
As with the other APIs we’ve examined throughout this series, there are four primary functions that we’re going to explore:
add_comment_meta
update_comment_meta
get_comment_meta
delete_comment_meta
By now, you likely know what to expect when it comes to, say, the differences between adding comment metadata and updating comment metadata. Or, say, working with deleting comment metadata.
That doesn’t change the fact that it’s worth exploring each of these API functions in detail to make sure we’ve covered all there is to know when working with them.
For the rest of this article, I’m assuming the following:
You’re running a local development environment with a web server, database server, and PHP.
You have a copy of WordPress installed.
You have a copy of tutsplus-metadata.php set up in your theme’s directory, and it’s included in your theme’s functions.php file.
You have your IDE and database front-end of choice readily available.
As I’ve used throughout the previous articles, I’m using the following applications:
Finally, all of the metadata with which we’ll be working is stored in the wp_commentmeta database table, so all of the screenshots that you see of the database will be of that particular table.
Unlike some of the other metadata tables that we’ve seen, the wp_commentmeta table starts off empty (assuming you’re working with a relatively fresh version of WordPress).
This is good as it will give us a clean slate, of sorts, to use when examining the various API functions. Note that for all of the examples below, we’re going to make sure all of this happens on the Hello World! post. This post has the ID of 1. If you want to use another page, simply replace 1 with the ID of the post in question.
With all of that in place, let’s start looking at what’s available.
Adding Comment Meta
In order to get started adding metadata to our comments, it’s important to take a look at the wp_comments table to see what comments already exist. If you’re working with a fresh installation of WordPress, then you’ll likely see a single record:
This is the default comment that ships with WordPress, and it will do fine for the examples we’ll be using.
If, on the other hand, you’re working with a database full of comments, no problem! All you need to know is what comment you’re working with (via its ID), and make sure you’re consistent with the code we use below.
As with other APIs we’ve reviewed in this series, adding metadata to comments comes in two forms: unique and non-unique. We’re going to review both.
Adding Unique Metadata
The add_comment_meta function accepts three parameters and an optional fourth parameter. If you pass true as the fourth parameter, then the metadata will only be added if the specified meta key doesn’t exist.
Make sense? Let’s take a look. First, we’ll set up a function that will add some metadata associated with the first comment (but will only do so on the post having the ID of 1):
Notice that I’ve passed the true parameter. So each time I refresh the page, WordPress will see that I want this value to be unique so it will not add any more information to the database table associated with that meta key.
Adding Non-Unique Metadata
If, on the other hand, I want to associate multiple values with the same meta key, I would remove the true parameter. For example, use the following code:
And then refresh the page, say, three times. If all goes as expected, you can see three new records, each of which contains a random number as generated by the call to rand() in the meta value argument.
It’s easy enough to keep straight, right? If you want a single value associated with a single key, then pass true as the optional fourth argument; otherwise, don’t specify anything.
Updating Comment Meta
If you want to update existing comment metadata, then it’s important to know the comment ID, the meta key, and the meta value. This means that WordPress will look at the specified meta key and associate it with the specified meta value.
If the meta value exists, then it will be overwritten. If the meta value does not exist, then it will be created. Notice in that last sentence that there’s a bit of functionality that you can use when adding metadata: If you want to have a unique piece of information written to the metadata table, then you can use update_comment_meta and it will write it as a unique value.
This may result in a bit of confusing code (since it reads as if it’s updating something that doesn’t exist), but it also allows you to enforce that only a single record will exist for the given meta key.
What happens when there is a meta key associated with several meta values? In that case, you need to know the value that you’re looking to replace. In some instances, you may know exactly what this is. In other instances, you may need to retrieve the information to find it (which we’ll cover in the next section).
Assuming that we want to update one of the records we’ve created, such as one of the random numbers we saw in the example above, we can look it up using the database front-end:
And specify it as the previous value in the following code:
After that, we can refresh the page, take a look in our database, and see the change. Note that the work we just did is relevant to a development environment and is not the way in which you would go about handling this in production.
Instead, you may need to run a query or retrieve a set of values before updating them. This leads us into the next topic.
Retrieving Comment Meta
Whenever you’re retrieving comment metadata, you need to decide if you want to retrieve a single value or all of the values associated with the specified meta key.
Perhaps another way of looking at this is as follows: If multiple pieces of metadata have been added with the same meta key (which we covered in the Adding Unique Metadata section above), then you will likely want to retrieve the entire collection of records.
If, on the other hand, you only want to retrieve one record because you know it’s unique or because it was created with the update_comment_meta function, then you want WordPress to return it to you in a single value.
The get_comment_meta function requires three arguments and an optional fourth depending on what you want to retrieve.
Retrieving an Array
Let’s say that you’re looking to retrieve a collection of all values associated with a single meta key. To do this, you would make a call to get_comment_meta and you’d specify the comment ID and the meta key.
In the code above, we’re printing it out to the web browser, but you would be able to work with this data in any way you’d like once you’ve retrieved it. The most important thing to notice, though, is that the value is returned as an array.
Retrieving a Single Value
If you want to retrieve a single value, then you only need to specify the comment ID and the meta key in the get_comment_meta function. If you happen to be dealing with a meta key with multiple values, then the first value that was created is what will be returned.
For example, let’s say there are three records associated with one meta key, and you only want to retrieve one value. Your code will look like this:
And the resulting value will look something like this:
string(9) "967432645"
Alternatively, if you know the data is unique, then the code will still look the same, as will the returned value.
The only difference is that the first example was retrieved from a set of multiple records, and the second example was retrieved from a single record. Also note that if you’re dealing with a unique value, then it will still be returned to you as an array, but a single index array.
This is important to note because if you plan on doing any type of comparison, especially to a value of a different type, such as an integer, then you will need to grab the value from the array, and you will likely want to do type conversion before making a comparison.
Deleting Comment Meta
Deleting metadata is a straightforward operation: It requires the comment ID, a meta key, and an optional meta value.
If you don’t specify the meta value, then all records associated with the meta key will be removed. If, however, you specify the meta value, then only that single record will be removed.
Removing Unique Values
For the purpose of this example, assume that we know a single piece of metadata exists for a given meta key. This means that the meta key must be unique for each user, so perhaps it uses something like a uniquely generated ID, a time stamp, or something similar.
To remove a unique value, we simply pass the comment ID and the meta key:
Before running this code, the database should look something like this:
After you refresh the page, take a look at the database and you should see that the record has been removed and the database should look like this:
We’ll talk a bit more about precautions to take when deleting data in the next section.
Removing Non-Unique Values
In other situations, let’s say there are multiple values associated with a single meta key. We’ve seen this numerous times throughout this article. If you want to delete all of the records associated with a meta key, then you don’t need to specify a meta value.
That is, if you just pass a comment ID and meta key to the delete_comment_meta function, it will remove all pieces of comment metadata. Write and execute the following code:
Refresh your page and then review the database. If there were no problems, your database should be clear of all records that previous had that meta key:
But remember that removing data from a database can be dangerous, especially if you accidentally delete something that you never meant to delete. To that end, it’s important to keep backups of your database in production environments so that you can always restore it if something goes wrong.
Further, this demonstrates why it’s so important to have a local development environment and a staging environment for testing before deploying the code to a production environment.
The Complete Source Code
As provided throughout this entire series, here’s a copy of all of the source code that we’ve covered in this article. It’s fully documented and includes comments not shown in some of the sections above.
<?php
/**
* This file shows how to work with the common Comment Meta API functions.
*
* Namely, it demonstrates how to use:
* - add_comment_meta
* - update_comment_meta
* - get_comment_meta
* - delete_comment_meta
*
* Each function is hooked to 'the_content' so that line will need to be
* commented out depending on which action you really want to test.
*
* Also note, from the tutorial linked below, that this file is used form
* demonstration purposes only and should not be used in a production
* environment.
*
* Tutorial:
* http://code.tutsplus.com/tutorials/how-to-work-with-wordpress-post-metadata--cms-25715
*
* @version 1.0.0
* @author Tom McFarlin
* @package tutsplus_wp_metadata
*/
/* add_action( 'the_content', 'tutsplus_add_unique_comment_meta' ); */
/**
* Adds a unique meta key and meta value for a user's Twitter handle
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_add_unique_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
add_comment_meta( 1, 'twitter_handle', 'tommcfarlin', true );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_add_comment_meta' ); */
/**
* Adds a unique meta key and random meta value
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_add_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
add_comment_meta( 1, 'random_value', rand() );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_update_comment_meta' ); */
/**
* Updates unique meta key and unique meta value for
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_update_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
update_comment_meta( 1, 'unique_value', time() );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_update_specific_meta' ); */
/**
* Updates a unique meta key and random meta value with a specified value
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_update_specific_meta( $content ) {
if ( 1 === get_the_ID() ) {
update_comment_meta( 1, 'random_value', time(), '17123683' );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_get_comment_meta' ); */
/**
* Gets an array of the comment metadata associated with the meta key
* in the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_get_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
$arr_metadata = get_comment_meta( 1, 'unique_value' );
var_dump( $arr_metadata );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_get_all_comment_meta' ); */
/**
* Gets an array of all the meta values associated with the specified meta key
* in the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_get_all_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
$arr_metadata = get_comment_meta( 1, 'random_value' );
var_dump( $arr_metadata );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_get_one_comment_meta' ); */
/**
* Gets a single value from a set of values associated with a meta key
* in the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_get_one_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
$arr_metadata = get_comment_meta( 1, 'random_value', true );
var_dump( $arr_metadata );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_remove_unique_comment_meta' ); */
/**
* Removes a unique meta value associated with the specified key
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_remove_unique_comment_meta( $content ) {
if ( 1 === get_the_ID() ) {
delete_comment_meta( 1, 'unique_value' );
}
return $content;
}
/* add_action( 'the_content', 'tutsplus_remove_comment_metadata' ); */
/**
* Removes all meta values associated with the specified key
* to the comment metadata table associated with the comment having
* the ID of 1.
*
* @param string $content The content of the post.
* @return string $content THe content of the post.
*/
function tutsplus_remove_comment_metadata( $content ) {
if ( 1 === get_the_ID() ) {
delete_comment_meta( 1, 'random_value' );
}
return $content;
}
Note that if you include this with the code from the rest of the articles in the series, you will need to be careful. Since everything is registered with the same hook, you may end up with weird results.
To combat this, I recommend one of the following two scenarios:
Create three separate files: one for each of the types of metadata APIs we’ve examined.
Comment the add_action calls, except for the ones with which you’re currently working.
Either of these will make it easier to work with all of the code we’ve covered thus far.
Conclusion
Whether you’re working with a metadata API or one of the other APIs, each WordPress developer should always have quick access to the WordPress Codex for quickly researching what APIs are available and how they should be used.
As we’ve worked through this series, you should see how the API designed around metadata is consistent. This makes for an easy-to-use, powerful API for extending some of the core WordPress functionality.
Additionally, I’ve mentioned that there’s another metadata API that was introduced in WordPress 4.4. I plan to cover that in an upcoming series, but it will require an examination of some of the other functionality that’s based on it.
For now, we’ve covered plenty of material to help you level up your existing WordPress skills. Until the next article, remember all of my courses and tutorials are available on my profile page, and you can read more articles about WordPress and WordPress development on my blog.
WordPress has an active economy. There are themes, plugins, libraries, and many other products that help you build out your site and project. The open source nature of the platform also makes it a great option from which you can better your programming skills. Whatever the case, you can see what all we have available in the Envato Marketplace.
Feel free to follow me on Twitter as well at @tommcfarlin, where I talk about various software development practices, many of which are relevant to web development and many of which are specifically geared towards WordPress.
As with all of my articles, please don’t hesitate to leave any questions or comments in the feed below, and I’ll aim to respond to each of them.
This beginner’s tutorial is a great introduction to preparing print items for special post-print effects, like die-cutting and embossing.
You’ll use Adobe InDesign to create an elegant wedding invitation, and learn how to set up a print-ready file, complete with die line, foiling and embossing layers. If you’ve ever wanted to learn more about preparing your artwork for unusual print finishes, or just want to be able to create special wedding invitations with a professional look at home, this tutorial will be right up your street!
Before we dive into designing our wedding invitation, you need to understand a little about the post-print techniques we’re going to be preparing our invitation artwork for. In this tutorial, you’ll learn how to:
Set up a die-linearound the edge of the invitation, which will allow the invite to be die-cut after printing. This will give the finished invitation beautiful curved edges with a French-style look.
Prepare a spot color layer for metallic foiling—this will give the perimeter of the invitation a metallic gold print effect, making it appear luxurious and glamorous.
Set up a layer for embossing decorative elements onto the invite—embossing raises areas of the card’s surface, creating an elegant 3D effect which makes the invites feel extra tactile and luxurious.
While we will be creating the design below in the tutorial, the techniques you’ll pick up will be easily transferrable to other print projects. Why not try embossing a business card? Or applying metallic foiling to a book cover? The possibilities are endless!
For this tutorial you’ll need access to both Adobe InDesign and Adobe Illustrator. We’ll be creating the invitation in InDesign, but we’ll also hop over to Illustrator to create a vector design for the border of the card.
2. Create the InDesign Invite Template
Step 1
Let’s get started with creating the basic template for our invite.
Open up Adobe InDesign and go to File > New > Document.
Set the Intent to Print, Number of Pages to 2 and deselect the check box next to Facing Pages.
Under Page Size, adjust the Width to 175 mm and Height to 106.5 mm.
Keep the Margins at their default width, and add a Bleed of 5 mm to all edges of the page.
Click OK to create the new document.
Step 2
We now need to set up a series of layers in the InDesign document to help us separate the sections of post-print artwork. Note that we will also need to export the print effects layers as separate PDF files at the end of the process.
Expand or open the Layers panel (Window > Layers) and double-click on the default Layer 1 name to open the Layer Options window. Rename the layer Background Color and click OK.
Select New Layer from the Layers panel’s drop-down menu. Create a second new layer and rename it Typography. Click OK.
Repeat the process, creating a further five new layers in the following order. All layers which require a special post-print process should be described in uppercase letters:
Decoration
EMBOSSED DECORATION
FOIL BLOCK bleed
FOIL BLOCK inside
DIE LINE – DO NOT PRINT
You should end up with a sequence of seven layers in total, with DIE LINE at the top of the pile.
3. Create a French-Style Border for Your Invite
Step 1
Minimize your InDesign document for now and open up Adobe Illustrator.
You can choose to either create your own border design for the invitation using the drawing tools in Illustrator, or choose a decorative frame from a ready-made selection, like this range of elegant frames from Envato Market.
Either way, you want to make sure the border is 175 mm in Width and 106.5 mm in Height, to match the proportions of the InDesign document.
Keep the border as simple as possible—any overly detailed edges or corners will be trickier to die-cut. Something simple like the border shown below will work perfectly. Once you have your border vectorised in Illustrator, set the Stroke Color to [None] and the Fill Color to a solid color, like Black.
Select the vector border, and go to Edit > Copy.
Step 2
Return to your InDesign document and to Page 1.
Head over to the Layers panel and lock all the layers except the bottom layer, Background Color. Click on the layer to activate it.
Then head up to Edit > Paste. The vector border will be dropped onto the page.
Center the border on the page perfectly, then head up to the Controls panel at the top of the workspace and adjust the Fill Color of the border to [None].
Download a hi-res image of a plain sheet of paper or card, like this one from Envato Market, to give the invitation a bit of background texture. This will add even more tactile texture to plainer card stock, giving your invite a more vintage vibe.
Go to File > Place, select the paper image, and click Open. Arrange the image in the frame, and then go to Object > Effects > Transparency and reduce the Opacity a little, to around 70%.
Step 3
Expand or open the Swatches panel (Window > Color > Swatches) and create a new CMYK swatch. Name it Pale Oatmeal, and set the levels to C=11 M=13 Y=16 K=0.
Duplicate the swatch and create a tint of the swatch by double-clicking on the copy and moving the Tint slider at the bottom of the Swatch Options window down to 10%. Click OK.
From the Swatches panel’s menu, choose New Gradient Swatch.
Rename the swatch Ivory Gradient and set the Type to Radial. Click on the left-hand stop on the Gradient Ramp, choose Swatches for Stop Color, and select [Paper] for this, the lighter swatch in the gradient.
Click on the right-hand swatch and choose the Pale Oatmeal 10% Tint swatch from the selection of swatches. Click OK.
Select the paper-filled vector border and Edit > Copy, Edit > Paste in Place. Double-click inside the frame to directly select the paper image and delete it.
Set the Color Fill of the pasted border to Ivory Gradient.
Then head up to Object > Effects > Transparency. Set the Mode to Hard Light and Opacity to 60%, to be able to see some of the paper texture beneath. Click OK.
4. Set Up Your Die Line
Now we have the French-style shape for the invitation, we’re ready to set up the die line around the edge of the shape…
Step 1
Return to the Layers panel and unlock the top layer, DIE LINE – DO NOT PRINT.
Select the top border vector on the Background Color layer and Edit > Copy, Edit > Paste in Place.
Back in the Layers panel click on the arrow to the left of the Background Color name to reveal all the elements sitting in the layer.
Click and drag the pasted vector element (called <path>) up to the DIE LINE layer.
Then lock the Background Color layer and click on the DIE LINE layer to activate it.
Step 2
Select the vector border and set the Fill Color to [None]. Remove the transparency settings (Object > Effects > Transparency).
Set the Stroke Color to CMYK 100% Magenta from the Swatches panel. Open the Stroke panel (Window > Stroke) and adjust the Weight of the stroke to 0.5 pt.
Double-click on the Magenta swatch to open up the Swatches panel. For the die line, we need to highlight this in a spot color, so choose Spot for the Color Type and rename the swatch Magenta Spot. Click OK.
Go to Window > Output > Attributes, and with the magenta die line selected, check the box that reads Overprint Stroke. You can then close the Attributes window.
5. Create a Foil Border
Foiling is a technique of applying a special coating, such as metallic or gloss, to a specified area of our printed item. In this case, we want to apply a gold foiling effect to the outside border of the invitation*.
* You will have to specify to your printer the specific sort of foiling effect you would like to apply. The artwork only specifies where the foiling will be, not what sort of foil effect it will be.
Step 1
Return to the Layers panel and lock the DIE LINE layer. Unlock the Background Color layer once again.
Click on the arrow next to the Background Color layer name. Duplicate the <path> element by dragging and dropping it down onto the Create New… button at the bottom of the Layers panel.
Unlock the FOIL BLOCK inside layer and then move the pasted <path> element up onto this layer.
Lock the Background Color, and keep the FOIL BLOCK inside layer unlocked and active.
Step 2
Select the vector border and remove any Fill Color and Transparency effects already applied.
Set the Stroke Color to [Black] (we’ll pull out all foiling areas in this swatch), and from the Stroke panel increase the Weight to 5 pt and adjust Align Stroke to Align Stroke to Inside, pulling the black border inside the edge of the magenta die line.
Step 3
Return to the Layers panel and unlock the layer below, FOIL BLOCK bleed.
Make a copy of the black border on the FOIL BLOCK inside layer and move it down to sit on the FOIL BLOCK bleed layer. Then lock the FOIL BLOCK inside layer.
From the Stroke panel adjust the Align Stroke of the duplicate black border to Align Stroke to Outside, so that the black border on the bleed layer is pulled to sit outside the die line.
This FOIL BLOCK bleed layer simply allows the printer to apply the foil effect past the edge of the die line, which means that if there are any slight errors in cutting along the die line, the foiling will appear completely seamless.
Step 4
Unlock the DIE LINE – DO NOT PRINT, both FOIL BLOCK layers and the Background Color layer. Drag your mouse across the whole of Page 1 of your InDesign document and Edit > Copy.
Scroll down to Page 2. Before we paste, go to the Layers panel’s drop-down menu and just make sure that the Paste Remembers Layers option is switched on.
Go to Edit > Paste in Place to make a copy of all the layers’ content on Page 2, which will be the reverse side of our wedding invitation.
6. Create Some Embossed Decoration
As lovely as metallic foiling and a die-cut border are, we want even more!
Embossing is a lovely technique for giving invitation designs an extra-special feel. On this invitation, we’re going to create some border decorations to be embossed after printing.
Step 1
Scroll back up to Page 1 of your InDesign document. Lock all the layers, and then unlock the EMBOSSED DECORATION layer.
Download the free glyphs font IM Fell Flowers 1, and install it onto your computer.
Return to your InDesign document, and open up the Glyphs panel (Window > Type & Tables > Glyphs). From here you’ll be able to view all the glyphs available in the typeface.
Step 2
Create a text frame on Page 1 using the Type Tool (T). Set your type cursor in the text frame, and from the Character Formatting Controls panel running along the top of the workspace, set the Font to IM Fell Flowers 1.
From the Glyphs panel, choose a symmetrical glyph with one straight side, like the one I’ve selected here. Double-click the glyph to insert it into the text frame.
You can switch the orientation of any text frame by Control-Clicking (Mac) or Right-Clicking (Windows) > Transform > Rotate 90 Degrees.
Choose a second glyph, a smaller one this time, like the one shown here, and place it in a separate text frame.
Step 3
Select both glyphs and go to Type > Create Outlines to transform both glyphs into editable vectors.
Set both with a [Black] Fill Color and no Stroke Color.
Place the decorative vectors against the sides of the invitation, similar to the way shown below. Copy and Paste each glyph to create identical copies and Control-Click (Mac) or Right-Click (Windows) > Transform > Flip Horizontal or Vertical to make them mirror each other.
Step 4
Select all four glyphs and Control-Click (Mac) or Right-Click (Windows) > Group.
When you create an embossed design on the front of your print item, you also need to consider how the effect will look from the back, which will appear depressed into the paper.
Why not fill this area with some lovely color, to make the back of the embossing effect look even prettier?
First up, head back to the Swatches panel and create a new CMYK Process Swatch. Name it Midnight Blue, and set the levels to C=88 M=80 Y=41 K=42. Click OK.
Select the group of decorative vector elements on Page 1 and Edit > Copy. Scroll down to Page 2, and Edit > Paste in Place.
From the Layers panel, unlock the Decoration layer below the active layer, EMBOSSED DECORATION, and drag the copied <group> element down onto the Decoration layer.
Now on Page 2 you have a copy of the decorative elements that are no longer sitting on the embossed layer, so you can apply color and focus on making them purely decorative.
Adjust the Fill Color of the decorative vectors from [Black] to Midnight Blue.
7. Add Elegant Typography
You can transform the look of a wedding invitation by simply switching up the style of a typeface. Aim to find two fonts with contrasting qualities—two script fonts might look a bit fussy, but teaming a script with a cleaner sans serif makes for a lovely, balanced combination.
Baskerville (Italic)—this should be already installed on your system; if not, Libre Baskerville is a nice free alternative
Step 2
Create a new CMYK swatch, C=26 M=36 Y=75 K=13, and name it Antique Gold.
Lock the Decoration layer and unlock the Typography layer below.
Step 3
Use the Type Tool (T) to create two long text frames in the very center of Page 1.
Type in the names of the bride and groom in each frame, and set the Font to Learning Curve Pro Regular, Size 40 pt, Align Center and in Antique Gold.
Increase the weight of the type a little by adding a Stroke Color in the same Antique Gold to the text, with a weight of 0.2 pt.
Step 4
Add an ampersand (&) between the two names, set in a separate text frame and in Baskerville Italic, Size 15 pt, and in Midnight Blue.
Step 5
Add text frames above and below the names, with the information set in Fontin Sans Small Caps, Size 9 pt, Tracking 70, Align Center and in Midnight Blue.
It’s looking awesome!
Step 6
Use the Line Tool (\), and holding Shift while you do so, drag to create a straight line, and position it to the left of the ampersand.
From the Stroke panel (Window > Stroke) set the Type to Japanese Dots, 1 pt Weight and Stroke Color to Antique Gold.
Copy and Paste the line, positioning the second to the right of the ampersand, as shown.
Step 7
Scroll down to Page 2 and add details about the event using the same text formatting (in Fontin Sans), and using dotted gold lines to divide up sections of information.
8. Export Your Invitation Artwork
Now that you have your design finished (hooray!) you’re ready to export it for printing.
Remember that we’ve set up three different post-print effects in the artwork—a die line for die cutting, decoration for embossing, and the border of the invite which is going to have a foiling effect applied to it.
When you have this many post-print effects, it’s wise to export each effect as a separate artwork file, and specify to your printer which artwork is intended for which purpose.
First up, let’s tackle the die-line export…
Step 1
Return to the Layers panel and switch off the visibility of the FOIL BLOCK inside, FOIL BLOCK bleed and EMBOSSED DECORATION layers.
Go to File > Export and choose Adobe PDF (Print) for your Format. Name the file appropriately, like ‘Wedding Invite_DIE LINE Artwork’. Hit Save to open up the PDF Settings window.
From the list of Adobe PDF Presets choose [PDF/X-1a:2001].
Click on the Marks and Bleeds tab on the left-hand menu in the window. Ensure that Use Document Bleed Settings is checked, and hit Export.
Step 2
Great, now we’re ready to export the artwork for the foil blocking.
In this example, I think it will look great if we can have a gold metallic foiling on the front of the invite, and perhaps a dark blue gloss (or metallic—fancy!) border on the reverse side of the invite. To do this, we will need to export each page of the invitation as a separate file.
Return to the Layers panel and switch off the visibility of all layers except the FOIL BLOCK bleed and FOIL BLOCK inside layers.
Repeat the process above—export the InDesign file as a [PDF/X-1a:2001] PDF file, but make sure to only select Page 1 to export at first. Name the file ‘Wedding Invite_FOIL FRONT_GOLD_Artwork’. Add the bleed too before you export.
Repeat the process for Page 2 (the reverse), naming the PDF file ‘Wedding Invite_FOIL FRONT_BLUE_Artwork’.
Fabulous!
Step 3
OK, we’re nearly there… I promise! Just one last thing to do, and that’s to export the embossed decoration as a separate PDF file. The process is identical, as we have set up the embossed decoration in a [Black] color, and placed the content on its own separate layer (we’re so organized!).
Return to the Layers panel and switch off the visibility of all layers except the EMBOSSED DECORATION layer.
Repeat the export to Adobe PDF process, naming this file ‘Wedding Invite_EMBOSS FRONT_Artwork’. The embossed artwork is only on the front of the invite, so make sure that only Page 1 is selected before you export.
Conclusion
Fantastic work! You now have four separate print-ready PDF files, which are ready to send straight off to the printers. Make sure to discuss the post-print finishes with your printer, to make your brief crystal clear. Post-print effects are expensive to produce, so you want to make sure they will be perfect the first time.
In this tutorial, we’ve covered a huge range of transferable skills for producing print- and post-print-ready files. You now know how to:
Create a wedding invitation template in Adobe InDesign
Drop in vector graphics from Adobe Illustrator to create a die line border for your cards
Build up color and textures on the background of your designs
Set up a spot color, overprinted die line on a separate layer
Create and prepare a foil block design for creating metallic finishes on your cards
Add decorative glyph elements ready for embossing
Format elegant, beautiful typography on your invitations
Export your design as separate print-ready artwork files
Awesome work! This should put you in good stead for tackling other projects with special print effects.
If you’re looking for more wedding invitation inspiration, check out the great range of elegant invite templates over on Envato Market. Why not try adding embossing, foiling or a die-cut edge to customize one of these templates?
Download How to Create a Wedding Invitation With Cool Post-Print Effects
In a new file, press A to select all default objects.
Press 1
in numpad to get into front view. Press Del
to delete them.
Press Shift-A and add a Circle (Mesh > Circle)
In the Tool Options panel, which located at the bottom of the tool shelf—press T to toggle on if it is not there—
select Nothing for Fill Type.
Check Align to View so that the circle is not facing upwards.
Step 2
With the object selected, press Tab on the keyboard to get into edit mode.
Press A to select
all vertices.
Press E to extrude them and then secondary-click or press Esc or so that
the extruded vertices stays in their place of origin.
Step 3
Press Tab to exit edit mode. With the object selected, click on the
modifiers button in the properties window. Click on Add Modifier button.
Step 4
Select Solidify from the modifier list.
Step 5
Drag and increase the Thickness slider value until the circle is filled.
If the
normals appear inverted, for instance the mesh appear darker, then check the Flip
Normals tick box.
Step 6
Click on the materials button in the properties window, and then press the
New button.
Step 7
Rename the material to anything you want. I named it burst-white.
In the diffuse panel, click in the colour bar and select a colour.
In the shading panel, tick the Shadeless checkbox.
By doing so the materials will
be rendered as flat colour.
Step 8
Press Shift-Left Arrow to go to first frame. You can also use the playback
controls.
Step 9
With the object selected and in the modifier panel, move the mouse over the Thickness slider. Press I
to insert a keyframe for that value.
Step 10
Go to frame 21. You can either drag the green marker in the timeline or directly
click and type 21 in the frame counter.
Step 11
Click the Thickness slider, type 0 (zero) and press Enter.
With the mouse over the Thickness slider and press I to create another keyframe.
Press Shift-Left Arrow to go to first frame.
Press Alt-A to play the animation.
Press Esc to stop.
Step 12
Go to frame 21 again. Left click on the frame counter and type 21.
With the circle selected, press I on the keyboard to bring the Insert Keyframe
Menu. Select Scaling. This will create a keyframe for the current
scale and size of the object.
Step 13
Press Shift-Left Arrow to go back to frame one.
Step 14
Select the object and press S to scale and then 0 to scale it down to the
full.
Step 15
Press I in the keyboard to bring out the Insert Keyframe Menu, and select Scaling.
Press Alt-A to play the animation. The circle will now grow from point to full and then disappear.
Step 16
On the top bar, click on the layout button and select Animation.
Step 17
Change the Dope Sheet mode to Action Editor. Rename the Action to burst or anything suitable.
Step 18
Secondary-click on the first keyframe of the Thickness value of the Solidify
modifier.
Press Shift-D to make a duplicate and offset it a little bit to the
right. This will delay the start of the animation of the thickness value.
Go to first frame and press Alt-A to play the animation. The animation
will look much better now.
Step 19
Change the bottom part to NLA Editor. Click on the editor type button
and select NLA Editor.
Step 20
Press the button with two down arrows, to convert the action to NLA strip.
The action is now converted to a strip which can be moved in the timeline as
when and where the animation is needed.
Secondary-click on the strip to select it. Press G to move it where ever you want
the animation to start and end.
Adding Variations
Step 1
You can add some variety by duplicating the original object and then tweaking
it. Secondary-click on the object to select it and then press Shift-D to make
a duplicate.
Secondary-click or press Esc so that it stays at the
origin. The
new object will also have the modifier and the action strip. It will
share the same material data with the original object.
Step 2
Press 3 in the numpad to get into sideview. Press G and move it away a little bit away from the first object.
Step 3
Since it shares the same material, click on the + button to make a new copy of the material settings,
which is needed for the new object.
Step 4
Rename the material to burst-red. In the Diffuse panel, click on the color bar and choose a colour. Make sure the Shadeless tickbox is checked.
Step 5
In the NLA editor, secondary-click on the action strip associated with the new object—which was automatically duplicated—
and select it. Press G and move it just a little bit to the right of
the timeline.
Press Shift-Left Arrow to go to first frame. Press Alt-A to play the animation.
Step 6
This whole setup can be applied to objects of different shapes. You
can also tweak the mesh anytime in the edit mode, which is difficult to do if you are using shapekeys.
Creating Circle Swipes
Step 1
In a new file, press A to select all default objects and press Del
to delete them. Press 1 in the numpad to get into front view. Press Shift-A to add a plane (Mesh > Plane).
In the Tool Options panel, which is located at the bottom of the tool shelf—press T to toggle on if it is not there—check Align to View.
This will rotate the plane.
Step 2
Secondary-click on the cube to select it.
Press Tab to enter edit mode.
Hold Shift key and secondary-click on the bottom two vertices one by one to
select them both.
Press Alt-M to bring out the Merge menu and select At Center to
merge them.
The two vertices will merge at the center of the distance between them
Step 3
Similarly select the top two vertices and press Alt-M to Merge them At Center.
Step 4
Press A to select all vertices. Press G to move them and Z to move them along the Z axis. Move the mouse
until the bottom vertex is at the centre point (orange dot) of the object.
Step 5
Press Tab to exit edit mode. With the object selected, click on the modifiers button in the
properties window.
Click on the Add Modifier button.
Step 6
Select the Screw modifier.
You’ll notice that the object has been transformed into a circle.
Step 7
Reduce the angle to 0 degree. This will return the object into its original
form. Increase the Steps and Render Steps to 24. This gives a smooth edge.
Step 8
Press Shift-Left Arrow to amke sure you are in the first frame. Move the
mouse over the Angle settings of the modifier and press I. This will insert a
key frame for the angle value which will then be animated.
Step 9
Go to frame 21. Click on the frame counter and type 21 or drag the marker to
frame 21 in the timeline.
Step 10
Click on the Angle slider and type -360. Move the mouse
over it and press I and this will insert a keyframe.
This
means that the value will change from 0 to -360 in the first 21 frames.
Go to first frame and press the Play button.
You’ll see the angle value being animated and thus giving a nice effect.
Step 11
With the object selected, click on the materials button in the properties
window. Click on the New button to add a material.
Step 12
Rename the material. I have named wit swipe-red.
In the Diffuse panel, click
on the colour bar and choose a colour. In the shading panel, tick Shadeless.
This will render the material with flat colour.
Step 13
In the top menu bar, change the layout mode to Animation.
Step 14
By default the top left window is the Dope Sheet Editor. Change it to Action
Editor so that we can see only the action associated with the selected object.
Step 15
Left click and rename the action to Swipe or anything else you want.
You can move the keyframe across the timeline to adjust the speed. Right
click to select the keyframe marker and G to move. Click to confirm.
Step 16
Change the bottom window to NLA Editor.
Step 17
In the NLA editor, click on the button with two arrows facing down. The action is converted
into a strip.
Step 18
The action now appear as a single strip.
You can now move this strip in the timeline as when and where you need the animation to start. Secondary-click to select it and G to move.
Duplicating and Adding Variations
Step 1
You can add more circle swipes for variety by duplicating the original object.
The duplicate will also have the same material and animation properties, so you
done need to animate it again.
Secondary-click on the object and press Shift-D to make a copy. Secondary-click again so that the object is placed back to its origin.
Step 2
With the new object selected, click on the material button in the properties window,
Press the + button to make a copy of the material for the new object.
Rename the material. I have renamed it swipe-white as the second object will be white in this example.
Step 3
In the Diffuse panel, left click on the color bar and set the new colour. Ensure the
material is Shadeless.
Step 4
With the new object selected, press Tab in the keyboard to enter edit mode
Press A to select all vertices and then pres G to move
Move the mouse and the vertices upward
Click to confirm.
Secondary-click on the top vertex and move it down to make a thin strip
Step 5
Press Tab to exit edit mode. Press Shift-Left Arrow to go to first frame and then press Alt-A to play the animation.
Step 6
You can delay and offset the animation of the second object. Secondary-click on the action strip of
the second object in the NLA editor.
Press G and move the mouse a little bit. Click to confirm.
Go to first frame and press Alt-A to see the animation.
Step 7
Next step is to close the circle back and make them disappear.
Select the strip
by secondary-clicking on it
Press Shift-D to
duplicate it
Move it towards the right of the timeline
Left click to confirm
Again do the same for the other object.
Step 8
With the mouse on the NLA editor, press N to bring out the properties panel.
Select the second action strip of any one object.
In the Active Strip panel, check Reversed. This will play the animation backward.
Do the same for the
second action strip of the other object.
Press Shift-Left Arrow to go to first frame. Press Alt-A to see the animation. Press Esc to stop.
Download Creating Motion Graphic Elements in Blender Without Shapekeys or Addons: Part 2
Game of Thrones season 6 is just around the corner! If you want to pass the time and learn something along the way, with this tutorial you’ll be able to create your own GoT tattoo design. I will show you how to plan the composition and how to paint it using black and white with an optional color accent. I will be working in Adobe Photoshop, but you can use any other software for it.
If you’d like to use my method to create a tattoo in some other style, you can find inspiration by checking the tattoo category on Envato Market. For example, you may like the design of this beautiful lion tattoo, or the colors of Heart Shaped Dream Catcher With Feathers.
1. Plan the Composition of the Tattoo
Step 1
Create a New File with square dimensions. Use the Ellipse Tool (U) in Shape mode to draw an outline of a circle in the center of the canvas.
Step 2
Duplicate (Control-J) the circle and use the Free Transform Tool (Control-T) to create a bigger circle. Hold Shift and Alt to keep the proportions.
Step 3
Use the Rectangle Tool or the Line Tool to draw a line crossing both circles. Duplicate it (Control-J) and use the Free Transform Tool (Control-T) while holding Shift to rotate it. Repeat as many times as necessary.
Step 4
Hold Shift and click the layers to select them. Group them (Control-G) and lower the Opacity of the group to make the guidelines almost invisible.
2. Plan the Position of the Elements
Step 1
Create a New Layer (Control-Alt-Shift-N) outside the group. Do this for every step, so that you can fix them later separately.
Use a sketching brush to sketch your idea loosely. My plan is to portray the sigil animals of the four houses chasing each other around the wheel: the Lannisters’ lion (1) chasing the Baratheons’ deer (2) chasing the Targaryens’ dragon (3) chasing the Starks’ direwolf (4). If you’re a fan of the series, you probably know why they’re placed like this!
Step 2
Adjust the shape of the bodies to the composition circle. The lion and wolf can be easily adjusted, but we need to put more effort into the bodies of the deer and dragon.
Step 3
Draw the spine of every animal to establish perspective.
Step 4
Time to draw the limbs. They should be very simplified and clear. You can draw them all with one method:
Step 5
Before we start working on the heads, mark the perspective once again to decide what every animal is looking at.
Step 6
Draw the heads following the perspective.
Step 7
Sketch the other elements, like tails and necks.
This is the sketch of the tattoo. If you don’t like something about it, now is the time to fix it.
3. Color the Tattoo in Black and White
Step 1
Group all the sketch layers and lower their Opacity.
Step 2
Create a New Layer outside the group. Use a hard brush to paint the outlines of every body. Make it as sketchy as possible, without redundant details.
Step 3
Use the Magic Wand Tool (W) to select the area outside the outlines. Invert the selection (Control-Shift-I), create a New Layer, and fill it with black using the Paint Bucket Tool (G).
Step 4
Create a New Layer. Right click it and select Create Clipping Mask. Fill this layer with white and lower the Opacity a little bit to make it stand out from the background.
Step 5
Add a Layer Mask to the layer (you can learn about it in Quick Tip: Layer Mask vs. the Eraser Tool in Adobe Photoshop) and fill it with black to make the layer content disappear. Now use a white brush to reveal some parts, as if there were a light source in the center of the circle.
Step 6
Use this “light” to reveal the basic form of every body.
Step 7
Add details to the shadow by switching between white (painting light/erasing shadow) and black (erasing light/painting shadow) in the Layer Mask.
Step 8
Set the Opacity back to 100%. Can you see how the white parts blend into the background? Let’s fix it.
Paint more details, still working in the Layer Mask.
4. Finish the Details of the Design
Step 1
Hide the lines completely to see how it looks. For me, there’s too much white space in the bodies, so I’ve added a few details to make the animals more recognizable.
Step 2
If you want to add a color accent, create a New Layer and draw red eyes for every animal.
Step 3
To make the eyes stand out more, create a New Layer below the previous one and draw dark patches around them.
Step 4
If you feel the lines are not clean enough, you can use Filter > Filter Gallery > Artistic > Cutout to smooth them. Also, for presentation purposes, I have added the Filter > Filter Gallery > Texture > Texturizer filter. Both filters can only be used if the picture has been flattened.
Winter Is Coming!
Our tattoo design is done! I hope you enjoyed following this tutorial. If you want to share your end result, please use the comments section—I’d love to see your interpretation!
Download How to Design a Tattoo With a Game of Thrones Theme
When starting out with a new platform, such as Shopify, there’s a lot to learn. Whilst Liquid, the template language used in Shopify themes, is very readable and easy to get started with, one area of Shopify development which can often cause confusion for new theme developers is images. I believe the main reason for this lies with understanding the “type” of image that you encounter within a Shopify theme. Over the course of this article we’ll examine each different type of image and how to use them within a Shopify theme.
If you are new to Liquid my three part series will give you a solid grounding and will be helpful as you follow along. If you are new to Shopify you can experiment with any of these techniques using a free development store. In order to create a development store sign up to the free Shopify Partner program.
Image Types
There are four types of images in a Shopify theme. You’ll work with each of them across a theme, so it’s important to understand the differences between them. Let’s examine each one in turn:
Theme images: these are stored within a theme’s assets folder and are specific to that theme. These are usually added to the theme by a theme developer.
Product images: these images are specific to a store and uploaded via the Shopify admin for each product.
Collection images: a single image assigned to represent a collection which is uploaded via the Shopify admin.
Article images: a single image assigned to represent a blog article which is uploaded via the article edit page in the Shopify admin.
It’s important to note that product, collection and article images are all linked directly to the store. If you change the store’s theme these images will remain in place and will work with any given theme that references them.
1. Theme Images
Let’s begin by looking at theme images. When creating a Shopify theme you can add any number of images, in any format and at any size to the assets folder within your theme directory. Typically these images can be used for backgrounds, sprites, and branding elements.
Referencing these images in a theme is very straightforward. Let’s assume we have a logo.png in our assets folder; we can output it in any template using the following Liquid syntax:
{{ 'logo.png' | asset_url | img_tag: 'Logo' }}
This approach uses two Liquid filters to create a fully formed HTML img element. The first, asset_url, prepends the full path to the assets folder for the current store’s theme. The second, img_tag, takes this and creates an HTML img element complete with alt attribute. If omitted the alt attribute will be blank. Here’s the end result:
You’ll notice that the src attribute references the Shopify CDN (Content Delivery Network). Every image that you add, regardless of its type, will be distributed to the CDN. This helps ensure fast delivery of your store’s images to the customer.
Unlike self hosted image files you have no way of knowing the exact server location for your image files. Luckily, you don’t need to worry about this as the Shopify specific asset_url Liquid filter will provide the path for you when your page is rendered.
Abstracting the full server path away to a filter also means that your themes are fully transferable from one store to another. The correct URL gets included depending on the theme and the store being viewed.
Adding Classes to the img Element
In the example above we added the alt attribute via the img_tag filter. It’s also possible to add a further parameter which allows you to add classes to the img element. Here’s our code refactored:
There will of course be occasions where you need a little more control over your HTML. By omitting the img_tag filter we can build up our markup as we wish.
Here’s an approach which would allow you to add your own attributes such as id:
It’s also pretty easy to use these assets in both CSS and JavaScript files. In order to do this append .liquid (e.g. styles.css.liquid) to a CSS or JavaScript file in your assets folder and reference the image, in your CSS file, using the same Liquid code we used above:
body { background: url({{ 'logo.png' | asset_url }}) repeat-x top left; }
Theme images are relatively straightforward. As long as you understand how to use asset_url you can choose whether or not to add the extra img_tag filter or build up the img element yourself.
Product, Collection and Article Images
Whilst we have full control over our theme images we are at the mercy of store owners when it comes to product images. Thankfully Shopify goes a long way to helping us regain that control. Let’s begin by looking at what happens when a merchant uploads an image in the Shopify admin.
Each time a product, collection, or article image is uploaded Shopify takes that image and automatically resizes it into a number of predefined sizes. These images are “namespaced” so that we can easily reference them in our themes.
Here’s the list of sizes with their corresponding image names:
16 × 16
pico
32 × 32
icon
50 × 50
thumb
100 × 100
small
160 × 160
compact
240 × 240
medium
480 × 480
large
600 × 600
grande
1024 × 1024
1024×1024
2048 × 2048
2048×2048
Largest image
master
Automatic Resizing
The values above specify the “maximum” bounds of an image size. All resized images will keep their aspect ratio and will be scaled accordingly.
This could mean that a “medium” picture has a width of 240px but a height of only 190px and likewise a height of 240px but a width of 80px. It’s for this reason most theme developers request that their clients upload square images as they will be more predictable.
The “master” image size will always track the largest size available from the server. Currently this is 2048px × 2048px. If you upload an image larger than 2048px wide you won’t have access to its original form.
It’s also worth noting that the originally uploaded product image will never be scaled up in size. If you upload a tiny image, it will remain tiny. You can of course reference the image by using any of the above image names. However, note that if you request a size that wasn’t possible to create then you will be served the closest available size.
Also bare in mind that if manipulated with CSS (e.g. width: 100%) the image may be scaled up and may become pixelated (depending on its format). When working with clients encourage them to upload high resolution square images where possible.
Finally it’s worth remembering that we don’t have access to product images in our theme’s folder. They are stored on the Shopify CDN and remain attached to the store regardless of the theme that is applied.
2. Displaying Product Images
Unlike theme images product images do not make use of asset_url. In order to output a product image we can make use of the img_url Liquid filter instead. This is due to the fact that product images are related to the store and not part of the theme’s assets.
img_url returns the URL of an image and accepts an image size as a parameter. It can be used on the following Liquid objects:
Each of these will return the fully qualified URL to the image stored on the Shopify CDN.
To demonstrate let’s have a look at some example Liquid code from a typical product.liquid template. As this particular template has access to the product variable all of these examples will work. However, please note that they won’t work as expected in other templates.
In this first example the value of image will represent each image in the collection and have a different value through each iteration of our Liquid loop. This variable can be named however you see fit; I am using image as it contextually it makes sense.
{% for image in product.images %} <img src="{{ image | img_url: 'grande' }}"> {% endfor %}
Once you have been working with themes for sometime you might notice other filters being used in relation to product images. Here are some alternatives that could be used in our example above, each of which would have the same output:
It’s entirely up to you which you choose to use. If you prefer one method over another you can always leave a comment using {% comment %}…{% endcomment %} explaining your decision. This is especially useful when collaborating on themes.
Displaying product variant images
In addition to product images it’s also possible to display images relating to the products variants. A variant can be explained as a variation of the product. Let’s say we have a t-shirt with a particular print on it. This t-shirt may come in green, blue and red. Whilst the print stays the same the colour of the t-shirt itself is different. It’s still the same product, but we have chosen to enable the customer to pick from certain options. Often these will be size and colour.
Variants can also have their own price and inventory level. It’s possible to associate a particular image to each variant–in addition to the main product images. If your theme uses variant images you can display them in the following way in the product.liquid template:
{% for variant in product.variants %} {% if variant.image %} <img src="{{ variant | img_url: 'small' }}"> {% endif %} {% endfor %}
alt Attribute
If you wish to add the alt attribute to your output you can do so as follows:
{% for image in product.images %} <img src="{{ image | img_url: 'grande' }}" alt="{{ image.alt }}"> {% endfor %}
This will output the alt text entered in the Shopify admin, or blank if nothing was entered. Alternatively, you could do the following if you choose to use the img_tag filter:
In our above example we used a Liquid loop to access each of the images associated with a product in turn. If the product had one image we’d output one image, if it had ten associated with it the loop would output ten images.
In Shopify the first image listed in the admin is also known as the “featured image”. Thankfully outputting the “featured image” is nice and straightforward and doesn’t require a loop. Here’s an example that would work in the product.liquid template:
I often describe a collection in Shopify as a logical grouping of products. For example it could be t-shirts, jeans, and dresses for an apparel store. A product can sit in zero, one, or many collections, allowing for easy categorisation and discovery.
Often, merchants will wish to include a page on their store detailing all of their available collections. The template that makes this possible in Shopify is list-collections.liquid. Here’s an example of how you can loop over every collection and output the image associated with it from within that template:
{% for collection in collections %} {{ collection.image | img_url: 'compact' | img_tag: alt: collection.title }} {% endfor %}
You could extend this example further to ensure that you catered for the situation where a collection image hadn’t been added:
In this instance we are using a theme image in place of the collection image. This will only be rendered if there is not an associated collection image. In order for this to work as intended you’ll need to ensure there is an image titled collection-image-default.png within your theme’s assets folder.
4. Article Images
Article images function in much the same way as product and collection images. Here’s an example:
If the article has an associated image then it will be displayed and given the alt attribute of the article’s title. There are a few ways collection and article images can come in useful:
To create a grid of images in a listing page
To use as background images which you can overlay text
Images Uploaded via “Customise Theme”
The final piece of the puzzle involves images uploaded via the “Customise Theme” option.
Every theme has a config folder. In it you’ll find a file called settings_schema.json. This file helps us generate an admin interface that allows merchants to add data such as text, boolean values (true/false), select fonts, upload images and much more. We are able to define these interface elements using JSON.
To enable an image upload you need to add a new element to the settings_schema.json file in the following format:
Images uploaded through the “Customize Theme” page are added to the theme’s assets folder. As such I didn’t include them as a separate image type at the beginning of the article.
The image file is saved with a name and format which matches the id attribute regardless of the file’s original name or format. For example image.jpg file would be saved as shop_logo.png. Shopify will attempt to convert the uploaded file to the appropriate format (.png) before saving it. If Shopify is unable to convert the file to a .png file, the user will receive an error message in the admin.
You’ll notice that the input type is image which results in an upload button appearing in the browser. You can also specify a maximum height and width for an image upload by using data attributes. Shopify will then maintain the aspect ratio of the uploaded image while constraining it to those maximum dimensions.
Referencing images added via “Customise Theme” is done in the same way as all other theme images:
{{ 'logo.png' | asset_url | img_tag: 'Logo' }}
Name Spacing Customise Theme Uploads
One thing you might wish to consider is using the id attribute to “namespace” your theme setting uploads. This way they are easy to spot in the assets folder as they will be grouped together. It also helps accidentally overwriting files that you add into your theme.
In the middle of 2015 Jason Bowman noticed that the Shopify checkout was displaying cropped square images. You can read about his discovery on his Freak Design blog.
Jason’s investigations led him to discover that all the checkout images were appended with _cropped. Here’s an example:
product-cropping-test-001_1024x1024.png
when cropped becomes:
product-cropping-test-001_1024x1024_cropped.png
The cropping works for all sizes except Master. In order to use cropped images we add _cropped to our img_tag filter. Here’s an example for a product featured image:
At the time of writing this is undocumented so there’s always the possibility it may change, but I wanted to include it.
Final Thoughts
We’ve covered a lot of ground in this article but hopefully it’s shown you how flexible Shopify is when it comes to working with images in a theme.
Images are an integral part of any ecommerce store. Understanding how images are managed and manipulated in a Shopify theme is an important part of learning Liquid and the Shopify platform.
Hopefully you’ll agree that the tools within the Shopify platform and Liquid allow you a lot of flexibility when it comes to working with images in your themes.