media-storage-in-magento

All Things You Should Know about Magento 2 Media Folder

Posted by

Magento 2 media folder (also called Magento 2 media storage) is a useful tool that helps you arrange and approach media files stored on the server. However, some people are still unfamiliar with this term. That’s why we’re here to help you.

This article will give you all the things related to the main topic, including:

  • An overview of Magento 2 media folder
  • An easy guide to upload image in Magento 2 from media storage
  • How to upload file in Magento 2
  • How to configure static Magento media URL

A Clear Overview of Magento 2 Media Folder

media-storage-overview
>>> Check It Out: Magento PWA Studio Tutorial – Step by Step to Get Maximum Customers!

Magento 2 media folder or media storage is regularly placed in the file system on the same server as the Magento program files. The base URL configuration elects the link to the location of media files, and the editor can gain access to data when working on pages or immobile blocks.

In addition, media files can be controlled in a dataset, set on a divided server or content delivery network. We can adjust the editor to utilize either static or dynamic media URLs for the content of the catalog in a category or product description.

So, what can we do with the Magento 2 media folder?

In media storage, you can upload images from the storage and upload files to it, which we will give a clear guide in the next sections. And also, we will provide step-by-step instructions to configure static media URLs as well. So, let’s stay tuned with us!

How to Upload Image in Magento 2 from Media Folder?

There are several simple steps to add an image, which will be presented as follows:

First of all, you need to open the page or block to be edited by choosing Content from Admin Sidebar then tapping Pages or Blocks under Elements.

Then, please select one of the following methods to add an image:

Method #1: Using WYSIWYG Mode

add-image-1
>>> Have A Look Here: Magento Frontend Developer Guide – The Key to Business Success!

STEP 1: Click on the Insert Image tab on the toolbar of the WYSIWYG editor

STEP 2: Choose Browse after the Image URL section

STEP 3: In the bibliography on the left, select the Magento media folder storing the image

add-image-2

STEP 4: Click on Insert File after determining the title of the image

Method #2: Using HTML Mode

Using HTML mode is not as complicated as the previous method.

add-image-3

STEP 1: Place the cursor in the code containing the <img> tag

STEP 2: Click on Insert Image

How to Upload Files in Magento 2?

The initial two steps are equivalent to the way that you add an image:

STEP 1: On the toolbar of the WYSIWYG editor, tap Insert Image

STEP 2: Select Browse after the Image URL part.

STEP 3: Do one of the following in the left directory:

  • Go to the Magento media folder that you choose to keep the uploaded image.
  • Go to the location where you want to add a new folder > Click on Create Folder > Type the folder name > Choose OK

STEP 4: Use Choose Files to upload files and do the following:

  • Move to the place of the images in the index of your local computer
  • Choose each image that is to be uploaded
  • Click Open and the images are uploaded to the current media storage file

What Is Magento Media URL & How to Adjust The Static URL?

Introduction to Dynamic Media URL

magento-media-urls
>>> Read Later: All about URL Rewrites in Magento 2 You Should Know!

A dynamic media URL is defined as a relative reference to an image or other media resource. Dynamic media URLs can be utilized to connect straightforwardly to resources on your server, or files stored on a content delivery network.

Besides, dynamic media URLs can affect catalog performance, and as we have mentioned in the overview, either static or dynamic media URLs can be used to adjust the editor.

Like all markup tags, the command is located in double curly braces. Here below is a specific example of a format of dynamic media URL:

{{media url="path/to/image.jpg"}}

When rendering the page, dynamic URL directives are processed from HTML content. And every time the page is rendered, the content is scanned for {{media url=”…”}} and the corresponding media URL will replace each command.

However, we have to note that inserting many directives will have adverse effects when loading the first page, and the page is not cached. Therefore, you should use it with caution or discuss it with professional developers.

Dynamic Media URL vs. Static Media URL

dynamic-static-url

The main difference between static media URL and dynamic media URL is that while static media URL is a fixed URL, the other will change whenever you store content in a database and pull for display on pages.

Besides, 2 types of URL will look like this:

We can see the difference between those 2 types. Also, a dynamic URL is easily recognized as its link contains some special characters like: “?” “=” “&”.

Additionally, people sometimes prefer a static URL for several reasons. But the main reason is that with the dynamic URL, your page will display the same content but different URLs over time. So that users can hardly find the link they are looking for.

And how to switch to a static URL or dynamic URL? Check it out in the next part.

How to Configure Magento Media URL?

The steps to configure the media URL is relatively simple. You just have to change the configuration setting.

STEP 1: Go to Store > Setting > Configuration on the Admin Sidebar

STEP 2: Click on Content Management in the left panel

STEP 3: Expand the WYSIWYG Options, and it will be displayed as the following image

wysiwyg-options

STEP 4: Set Use Static URLs for Media Content in WYSIWYG to:

  • Yes: If you want to use static media URL
  • No: If you want to use dynamic media URL

STEP 5: When everything is all done, click on Save Config to finish

BONUS: How to Create A Magento File System Owner?

Security is one of the most worrying issues in e-commerce. Understanding people’s concerns, we give this as a bonus part that you can set access permission to prevent strangers from editing content on your website.

You can create Magento file system with a strong password with these 3 steps:

STEP 1: Run the command below to create the Magento file system owner:

adduser <username>

STEP 2: Enter the following command to give it a password:

passwd <username>

STEP 3: Follow the notification displayed on your screen to set a password

Conclusion

e-commerce-infographic
>>> Cannot Overlook: More Magento tutorial blogs for better e-commerce sites!

In this article, you must have had details about the Magento 2 media folder and some related things. And we hope that you are satisfied with all the information we have given in this tutorial blog. Therefore, you can easily optimize your e-commerce website.

If you need any help, please feel free to contact us. We’re 24/7 available.

Thanks a lot for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *