why do developers use their own media folders?

Relax and enjoy The Lounge. For all Non-Joomla! topics or ones that don't fit anywhere else. Normal forum rules apply.
Post Reply
User avatar
Gany
Joomla! Ace
Joomla! Ace
Posts: 1167
Joined: Wed Jan 02, 2008 12:38 am

why do developers use their own media folders?

Post by Gany » Sun Mar 10, 2019 12:35 am

Something that strikes me as a bit odd: some developers use their own media folders instead of the Joomla image folder. For example, Joomshaper does it with most of their extensions and in Page Builder, Solidres, and many others do it.

I can't think of any positive reason why. Also I think that is something Joomla should (strongly) discourage.

How do others think about that?

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22105
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: why do developers use their own media folders?

Post by pe7er » Sun Mar 10, 2019 9:28 am

Note that there's a difference between media and image folders.

The media folders (located in /media) are meant for 3rd party extensions to store their own images, CSS and JS files. A 3rd party component called "somecomponent" should use /media/com_somecomponent/images/ for its own images. It's recommended to do so because it's easier to distinguish the files that can be overridden.

However some 3rd party extensions put their own media files in /administrator)/components/com_somecomponent/assets/images/

The image folder /images/ is meant for images that are uploaded by the admins/users of the website.
IMHO 3rd party extensions could put the images in something like /images/somecomponent/
It's better so that the website owners can easier determine the uploaded media from the rest of the websites, e.g. when creating backups or when using a CDN.

Some 3rd party extensions put the uploaded images in /components/com_somecomponent/upload/images/ which makes it more difficult to distinguish "core" files and uploaded media.

The reason that some developers do so is history (they have always done it since 1.0 when this wasn't the way) or they like to have all their stuff in their own component folder.


When I develop custom components I use /images/ for uploaded media files.
And for my component's media files I mostly use /media/com_mycomponent/ when my component uses multiple media files.
If it's just a component icon, I might use the non-recommended way /administrator/components/com_mycomponent/assets/images/ instead.

Regarding language files, I put my language files in my own component, and not in Joomla's com_languages.
It's easier to maintain your own language files during development when they are in the same component folder.
And regarding multiple languages: my component might have languages included that are not yet in Joomla. When I have those in my component, they are available immediately when a new Joomla core language file is installed and activated.

The recommended way:
https://github.com/joomla-extensions/boilerplate
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content


Post Reply

Return to “The Lounge”