For example, in portfolio section I want to have 3 images that are positioned always in the same place in all the posts. I know there is a plugin that does this but I need to accomplish this without a plugin.
The best advice is to use the plugin. I can't think of any reason to rebuild functionality that already works well and exists. If you absolutely need this functionality in the theme, you can include the code from the plugin into your theme by removing the header in the plugin's main file and requiring it in your theme's functions.php file.
Please bear in mind that this is NOT considered as "best practice" and there are a couple of other steps that you will need to take to really make this work well:
At the end of the day, I would strongly urge you to allow your theme to support the plugin and degrade gracefully if the plugin is not installed.