To understand this post, you need to know something about Smarty and Wordpress. In addition you will not completely understand the article if you know nothing about object orientation and about MVC design pattern.
Wordpress is a powerful CMS that allows you to create every type of website (even if it was born to create blogs). Wordpress can be also used as a framework and not only as CMS. It's based on event programming. The developer is really free about the design choices. Personally, when I want to develop a Web application, I always use the MVC pattern and I like to use Smarty to manage the graphic rapresentation of the data.
When you create a view in Wordpress, you will need to use php code inside html. I don't really like this approach for data rapresentation. So when I develop applications using wordpress, I like to use Smarty for the realization of the GUI. Note that the following tecnique is not recomended when you are developing Wordpress templates: in this case my advice is to use the Wordpress classical approach.
When I develop applications in PHP, I usually use autoload function to get classes' paths. I write the code about autoload, inside a file called autoload.php. To make autoload works, you'll need to include that file inside "each" PHP class. Now, you can take advantage of Wordpress and avoid to "requre_once" autoload script inside each class. The way a Wordpress plugin works, can be rapresented by the following image:
As you can see, each class is used by the plugin, starting from plugin's main file. For this reason the autoload function can be used simply adding a "require_once" inside the main file of the plugin.
But how to write autoload when using Smarty? Suppose you have for your application only "Controller" and "View" classes, suppose that each "Controller" class name has a "C" as first character (each class has a name like: Cclassname), while the "View" classes have a "V" as first character. So the code for autoload.php should be something like:
In the tutorial above I will explain how to replace the face of a person using Photoshop. Thanks to this tutorial you will know how to replace your face (ore your body) in a few minutes.
1. Canvas creation
For this tutorial we'll need two images: one with the face and another with the body of the person to who we want to replace the face. For a good final result, my advice is to choose two images in which the faces are approximetly in the same position. In addition try to find two pictures with similiar light exposure.
I choose the pictures in FIG.1 and FIG.2
Fig.1
Fig.2
2. Modify light and shadow
If you are not a professional photographer, you will not have probably two pictures with the same light exposure. For that reason let's go editing the shadows on the face.
With Dodge Tool (use FIG.3 settings), draw on the face area covered by shadows until you have something like FIG.4. Do the same thing with the Dodge Tool setted like FIG.5. At the end you should have something like FIG.6
A problem that is fairly widespread when we develop websites templates, concerns the vertical alignment of images inside containers like divs. There are many solutions to this problem on the Web, but in many cases they are not useful, because they are relative to specifical situations and not to general ones. The solution I'm going to show will not have that problem, so you will be able to use the code above in many cases without modify it.
Suppose we have a square container (120px side) and suppose we want to put into the container a vertically centered image:
Now to allign the image vertically using css, we could use many css attributes, like margins or position. For example, if we know that the image is 80px high and 120px length, we could add to the img a margin-top of (120-80)/2=20 pixels:
In this way everything seems to work. The problem is that in many cases we don't know the size of the image we want to align. For example I was studying a case where I needed to extract a frame from some videos. The problem was that I didn't know exactly the ratio of the videos.
The previous solution was not useful to solve my problem. But, basically, the mechanism was working: the only thing to do was to automatically calculate the margin; for that reason I decided to make a JS script to get my target.
The variables we need to realize an "adaptive" script are:
Heigh of the container
Heigh of the images
Length of the images
The script will use the jQuery framework. We can make everything with a single JS function and we want to give to that function only the container's id.
Nel breve tutorial seguente, mostrerò una delle tecniche che si possono utilizzare per creare delle "orecchie da elfo" con Photoshop
1. Creazione della tela
Prendete una foto qualunque, possibilmente abbastanza definita, nella quale sia possibile scorgere (almeno) l'orecchio della persona che volete trasformare (FIG.1)
Fig.1
2. Selezione dell'orecchio
Bisogna selezionare l'orecchio. Al solito effettuate l'operazione utilizzando il Pen Tool (Strumento Penna), creando un tracciato simile a quello in FIG.2; ricordate che il tracciato deve essere chiuso (FIG.3). Ora con lo strumento Select Path (Seleziona Percorso), cliccate col tasto destro sul percorso creato e scegliete Make Selection (Trasforma in selezione). Premete OK nella finestra che comparirà (FIG.4).