• Hello, My main problem is how will I use DigitalOcean Object Storage for my wordpress’s static files and also themes files such as css,html,js etc with CDN and optimized functionality.

    I have successfully solved this issue of images with a plugin, but now i need the solution for other asset files and where the asset files are linked, because after uploading the asset files to the object storage I need to modify the links to work in the website.

    Again,
    I want to store my wordpress theme asset files or wordpress asset files into DigitalOcean Object Storage.

    I have successfully implemented the system for wp-content/uploads files to store those library images into DigitalOcean Object Storage through a plugin.

    Now, I just want to transfer my other css, js, images files into Object Storage and load them from the Object Storage link?

    How Can I do that ?

    As an example,

    there are some files in wp-includes > css, js, images

    Where are these files are used and how the links of these files are working?

    Now How can I upload these files to my object storage and load from the object storage link? Is there any plugin out there? or Do I need to change anything manually ?

    Please any help from wordpress developers would be appreciated.

    • This topic was modified 6 years, 4 months ago by raydvard.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    I advise you to only relocate assets that have filterable links. Altering links that are not filtered would require modifying core or other’s source files, which is strongly discouraged. Relatively speaking, WP assets do not amount to all that much resource and are not worth doing dirty hacks to accomplish relocation.

    As to which assets are filterable, it varies. You’d have to track down how each is referenced and trace through source code. Identifying filters in syntax highlighted source code is relatively easy, but all the various ways assets are referenced start adding up.

    Thread Starter raydvard

    (@raydvard)

    What do you mean by filterable links ?
    Well, no one has done it? I need to know which asset files are working together in wordpress from a wordpress developer, like
    wp-admin got it’s own css,js, images, icons files…
    and there are other static files, these files must be declared or used in a organised way. I just need to know which files are locating where and doing what.

    Then as you have suggested, I should not edit core files but I can relocate other files right ?
    I am trying to use of full facility of object storage and minimalist wordpress docker development.

    Thanks for the reply, any further reply to clear my understanding ?

    Moderator bcworkz

    (@bcworkz)

    You “just” need to know which files are where and doing what ?? That’s a much more complex topic than “just” a forum reply would be able to answer. There are many hundreds of resource files doing many things throughout the hundreds of core PHP files. Depending the nature of your site, many of these resources are little used, if used at all. Most are only a few kilobytes in size or less.

    Perhaps an even bigger issue is many of these files are updated when WP is updated. After each update, you would again need to move these files to DO storage.

    How and where these files are referenced in core is quite varied and diverse. For each file you want to move, find where it’s referenced in served pages, then identify the code responsible for that output. Review the code to see if there is an apply_filters() call or some related mechanism where the link can be altered through custom plugin code without altering core code.

    Let’s look at just one static file reference as an example. One of the most referenced of static files is /wp-includes/js/jquery/jquery.js. This file is not literally filterable by using add_filter() hooks, but it is a registered and enqueued script file, so it can be deregistered and reregistered using a new path.

    Script registration for front end pages is done during the “wp_enqueue_scripts” action. In your custom plugin, hook this action with a large priority argument so your callback is called later than core callbacks. Within your action callback, you might have this:

    wp_deregister_script('jquery');
    wp_register_script('jquery', 'https://www.storage-url.com/path-to-your-account/jquery/jquery.js');

    Now when any code enqueues jQuery, the script tag src attribute will reference storage-url.com instead of your domain name.

    Similar research and solutions are required for every file you want to move. In many cases, there may not be any solution available and the file cannot be properly relocated.

    Thread Starter raydvard

    (@raydvard)

    Okay, Thanks for the valuable information, I will try according to your suggestion and let you know the results.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using Object Storage for Assets Files’ is closed to new replies.