{"id":57,"date":"2022-10-05T13:27:48","date_gmt":"2022-10-05T11:27:48","guid":{"rendered":"https:\/\/wordpress.familie-lahme.de\/?p=57"},"modified":"2022-10-06T12:36:18","modified_gmt":"2022-10-06T10:36:18","slug":"wordpress-and-the-media-library","status":"publish","type":"post","link":"https:\/\/wordpress.familie-lahme.de\/index.php\/2022\/10\/05\/wordpress-and-the-media-library\/","title":{"rendered":"WordPress and the Media Library"},"content":{"rendered":"\n<p>I run WordPress on my own device at home. All the media files I am using and will be using are also hosted on a machine in my network using Nextcloud.<br>If I want to use a media file in a post I need to upload the file from Nextcloud to the WordPress server, which makes the file physically duplicated.<br>For images there is an option in Nextcloud to prevent this.<br>If I share a file public, I get a link to it like so:<br><a href=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/pXcBkCWNn7qTQd8\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/pXcBkCWNn7qTQd8<\/a><\/p>\n\n\n\n<p>You can now click on that link and you will be redirected to my Nextcloud instance and the file will be presented for downloading:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-084751-NextcloudScreen.png\" alt=\"\" class=\"wp-image-58\" width=\"503\" height=\"444\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-084751-NextcloudScreen.png 737w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-084751-NextcloudScreen-300x265.png 300w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p>But, if I modify this link like so:<br>&#8220;<a rel=\"noreferrer noopener\" href=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/pXcBkCWNn7qTQd8\/preview\" target=\"_blank\">https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/pXcBkCWNn7qTQd8\/preview<\/a>&#8220;<br>You still can click on the link, but you will only see the picture itself.<br>And this can be used in WordPress to embed the picture:<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/pXcBkCWNn7qTQd8\/preview\" alt=\"\" width=\"413\" height=\"307\"\/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>For video files, this method is not supported. Nextcloud is able to playback videos embedded on its own page, but it does not allow this for remote sites. As an example here is the Nextcloud intro video embedded like the image file:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/C6yGGnaanGYGTxy\"><\/video><\/figure>\n\n\n\n<p>As You can see, you can see nothing.<br>Here the link to the file: <a href=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/C6yGGnaanGYGTxy\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/C6yGGnaanGYGTxy<\/a><br>Now I extend the URL with the &#8220;preview&#8221; flag:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/nextcloud.familie-lahme.de:1443\/index.php\/s\/C6yGGnaanGYGTxy\/preview\"><\/video><\/figure>\n\n\n\n<p>And again, you can see nothing. So this &#8220;preview&#8221; method does not work for video files.<br>But as videos are mostly even the largest files you will use, it would be very space consuming to double those files by putting them on the image library on WordPress.<br>Most used simple solution is to put the files onto Youtube and embed them like so:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Nextcloud intro\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/5Zm0dDAPh5A?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>But what, if you don&#8217;t want to use any external storage -especially Google and its substitutes?<br>I have searched for WordPress and Nextcloud plugins for that, but did not find any usable and solid maintained ones.<br>At one point in time I was searching for a solution on another issue and came up with a tool, where you can mount WebDav drives to a system. It is called &#8220;davfs2&#8221; on Linux: <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Davfs2\" target=\"_blank\">https:\/\/en.wikipedia.org\/wiki\/Davfs2<\/a><\/p>\n\n\n\n<p>This gave the idea to me, that also would solve some other challenges if you work with multiple users and don&#8217;t want to take away the file control from the users. What if WordPress has its own Nextcloud user. If you now share a file in Nextcloud, the file pops up in the folder of that user. If the WordPress user now connects using webdav, the content of this drive equals the shared files. If we now put the mount point for that webdav drive into the upload folder of WordPress, it should be displayed in the image library.<br><\/p>\n\n\n\n<p>First thing first, lets install DAVFS2:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:~# apt update\nHit:2 https:\/\/httpredir.debian.org\/debian buster InRelease\nHit:3 https:\/\/security.debian.org buster\/updates InRelease\nHit:4 https:\/\/packages.sury.org\/php buster InRelease\nHit:1 http:\/\/mirrors.xtom.de\/armbian buster InRelease\nHit:5 https:\/\/httpredir.debian.org\/debian buster-updates InRelease\nHit:6 https:\/\/httpredir.debian.org\/debian buster-backports InRelease\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nAll packages are up to date.\nroot@derdapp003:~# apt install davfs2\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nThe following additional packages will be installed:\n  libneon27\nThe following NEW packages will be installed:\n  davfs2 libneon27\n0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 296 kB of archives.\nAfter this operation, 532 kB of additional disk space will be used.\nDo you want to continue? &#91;Y\/n]\nGet:1 https:\/\/httpredir.debian.org\/debian buster\/main armhf libneon27 armhf 0.30.2-3 &#91;151 kB]\nGet:2 https:\/\/httpredir.debian.org\/debian buster\/main armhf davfs2 armhf 1.5.5-1 &#91;145 kB]\nFetched 296 kB in 1s (426 kB\/s)\nPreconfiguring packages ...\n<img loading=\"lazy\" decoding=\"async\" width=\"957\" height=\"226\" class=\"wp-image-59\" style=\"width: 900px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-092918-image.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-092918-image.png 957w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-092918-image-300x71.png 300w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-092918-image-768x181.png 768w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-092918-image-850x201.png 850w\" sizes=\"auto, (max-width: 957px) 100vw, 957px\" \/>\n\nSelecting previously unselected package libneon27:armhf.\n(Reading database ... 44713 files and directories currently installed.)\nPreparing to unpack ...\/libneon27_0.30.2-3_armhf.deb ...\nUnpacking libneon27:armhf (0.30.2-3) ...\nSelecting previously unselected package davfs2.\nPreparing to unpack ...\/davfs2_1.5.5-1_armhf.deb ...\nUnpacking davfs2 (1.5.5-1) ...\nSetting up libneon27:armhf (0.30.2-3) ...\nSetting up davfs2 (1.5.5-1) ...\nProcessing triggers for man-db (2.8.5-2) ...\nProcessing triggers for libc-bin (2.28-10+deb10u1) ...\nroot@derdapp003:~#<\/code><\/pre>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p>Next step is to create a user in Nextcloud. I call him &#8220;WordPressMFL&#8221; and it will be a simple user, no special privileges.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-093705-image.png\" alt=\"\" class=\"wp-image-61\" width=\"332\" height=\"477\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-093705-image.png 388w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-093705-image-209x300.png 209w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-093705-image-300x431.png 300w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>Let&#8217;s check, what the User sees in his profile, if a file is shared with him:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-094538-image.png\" alt=\"\" class=\"wp-image-63\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-094556-image.png\" alt=\"\" class=\"wp-image-62\" width=\"305\" height=\"319\"\/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>On the left side You see the file explorer of the WordPress user. Note the Icons on the shared files.<br>On the right side you can see, that I shared the &#8220;NoThanksButWereBusy.png&#8221; has been shared from a subfolder &#8220;Bilder\/Backgrounds&#8221; on my regular user profile, but it pops up in the root folder of the WordPress user. Also note, that the two Nextcloud files shared by in this case my NC admin user obviously overwrite the original files in the WordPress user folder. The needs to be taken in account, if two users share the same file from a shared resource.<\/p>\n\n\n\n<p>Ok, now lets mount the WebDav share on the WordPress server:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:~\/tmp# mount -t davfs https:\/\/nextcloud.familie-lahme.de:1443\/remote.php\/dav\/files\/wordpress_mfl\/ ~\/tmp\nPlease enter the username to authenticate with server\nhttps:\/\/nextcloud.familie-lahme.de:1443\/remote.php\/dav\/files\/wordpress_mfl\/ or hit enter for none.\n  Username: wordpress_mfl\nPlease enter the password to authenticate user wordpress_mfl with server\nhttps:\/\/nextcloud.familie-lahme.de:1443\/remote.php\/dav\/files\/wordpress_mfl\/ or hit enter for none.\n  Password:\n\/sbin\/mount.davfs: warning: the server does not support locks<\/code><\/pre>\n\n\n\n<p>Check the mounts:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:~\/tmp# mount\n&#91;...a lot of unrelated stuff...]\nhttps:\/\/nextcloud.familie-lahme.de:1443\/remote.php\/dav\/files\/wordpress_mfl\/ on \/root\/tmp type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,max_read=16384,uid=0,gid=0,helper=davfs)<\/code><\/pre>\n\n\n\n<p>And now lets look, what we see in it:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:~\/tmp# ll\ntotal 17636\ndrwxr-xr-x 2 root root        0 Oct  5 09:42  Documents\n-rw-r--r-- 1 root root 12764917 Oct  5 09:43 'Nextcloud Manual.pdf'\n-rw-r--r-- 1 root root  3963036 Oct  5 09:39 'Nextcloud intro.mp4'\n-rw-r--r-- 1 root root    50598 Oct  5 09:43  Nextcloud.png\n-rw-r--r-- 1 root root   303078 Jul 18 19:57  NoThanksButWereBusy.png\ndrwxr-xr-x 2 root root        0 Oct  5 09:43  Photos\n-rw-r--r-- 1 root root   976625 Oct  5 09:39 'Reasons to use Nextcloud.pdf'\ndrwxr-xr-x 2 root root        0 Oct  5 09:43  Templates\ndrwx------ 2 root root        0 Oct  5 09:59  lost+found<\/code><\/pre>\n\n\n\n<p>Booyaa&#8230;. it works&#8230;.<\/p>\n\n\n\n<p>Be aware, that all permissions are now locked to &#8220;root&#8221; as I did this test within this users context.<br>At the end, we have to have &#8220;www-data&#8221; in there, if we mount it below the uploads of WordPress.<br>This being said, we also need a secure and stable way, to mount this share automatically on server boot, meaning, we have to store the password in a matter, where &#8220;www-data&#8221; can read it, but does not expose it to the internet by any malicious URL Request on the Web UI.<br>Another thing to mention here: In Linux a mount point is a folder, you have created before mounting the remote resource. If you have used this folder before mounting, all the data in it will not be displayed. The content is still existing, but the File IO will reroute the request to that folder to the remote resource, not reading, what is on the local file system.<br>So, if we mount to &#8220;wp-content\/uploads&#8221; we will &#8220;loose&#8221; our media library we used up to that point.<br>Two approaches, to solve this:<br>1. Move the files in the mount point to the remote share<br>2. Create a mount point below the original target (e.g. &#8220;wp-content\/uploads\/remote&#8221;)<br>We will go for scenario #2, as I have some other stuff in mind, that would make managing files in the library a little bit more easy, and keep in mind, that wordpress itself creates a folder structure within the upload folder using the dates of the uploads.<br>But again: First things first.<\/p>\n\n\n\n<p>Lets start with creating a mount point below the uploads folder:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:\/var\/www\/wordpress_prod\/wp-content\/uploads# ll\ntotal 4\ndrwxr-xr-x 3 www-data www-data 4096 Oct  3 16:23 2022\n\nroot@derdapp003:\/var\/www\/wordpress_prod\/wp-content\/uploads# sudo -u www-data mkdir nextcloud\n\nroot@derdapp003:\/var\/www\/wordpress_prod\/wp-content\/uploads# ll\ntotal 8\ndrwxr-xr-x 3 www-data www-data 4096 Oct  3 16:23 2022\ndrwxr-xr-x 2 www-data www-data 4096 Oct  5 10:20 nextcloud\n<\/code><\/pre>\n\n\n\n<p>Now we add the credentials to the file &#8220;\/etc\/davfs2\/secrets&#8221; for the mount point:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>\/var\/www\/wordpress_prod\/wp-content\/uploads\/nextcloud wordpress_mfl \"&#91;secretpass]\"<\/code><\/pre>\n\n\n\n<p>To allow the mount, we need to edit the &#8220;\/etc\/fstab&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>## wordpress remote media\nhttps:\/\/nextcloud.familie-lahme.de:1443\/remote.php\/dav\/files\/wordpress_mfl \/var\/www\/wordpress_prod\/wp-content\/uploads\/nextcloud davfs uid=www-data,gid=www-data,auto,rw 0 0<\/code><\/pre>\n\n\n\n<p>This approach means, that the mount is set on boot, and the user and group on that mount point is set to &#8220;www-data&#8221;.<br>Lets check that:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:\/# ll \/var\/www\/wordpress_prod\/wp-content\/uploads\ntotal 5\ndrwxr-xr-x 3 www-data www-data 4096 Oct  3 16:23 2022\ndrwxr-xr-x 6 www-data www-data  424 Oct  5 09:43 nextcloud\n\nroot@derdapp003:\/# ll \/var\/www\/wordpress_prod\/wp-content\/uploads\/nextcloud\/\ntotal 17636\ndrwxr-xr-x 2 www-data www-data        0 Oct  5 09:42  Documents\n-rw-r--r-- 1 www-data www-data 12764917 Oct  5 09:43 'Nextcloud Manual.pdf'\n-rw-r--r-- 1 www-data www-data  3963036 Oct  5 09:39 'Nextcloud intro.mp4'\n-rw-r--r-- 1 www-data www-data    50598 Oct  5 09:43  Nextcloud.png\n-rw-r--r-- 1 www-data www-data   303078 Jul 18 19:57  NoThanksButWereBusy.png\ndrwxr-xr-x 2 www-data www-data        0 Oct  5 09:43  Photos\n-rw-r--r-- 1 www-data www-data   976625 Oct  5 09:39 'Reasons to use Nextcloud.pdf'\ndrwxr-xr-x 2 www-data www-data        0 Oct  5 09:43  Templates\ndrwx------ 2 www-data www-data        0 Oct  5 10:59  lost+found<\/code><\/pre>\n\n\n\n<p>ok, now we do have a mount below the Media Library Folder. Let&#8217;s see, what WordPress shows us in the Web UI:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/2022\/10\/20221005-110616-image.png\" alt=\"\" class=\"wp-image-65\"\/><\/figure>\n\n\n\n<p>Nope, that does not fit. No subfolder &#8220;nextcloud&#8221; and no images from it in here.<br>At this point we need a plugin, to get the files into the database. WordPress heavily relies on data records to identify its environment. A file on harddrive not mentioned in the database, does not exist from WordPress perspective.<\/p>\n\n\n\n<p>I found a tiny plugin, that fulfills the needs here: <a href=\"https:\/\/wordpress.org\/plugins\/media-sync\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/wordpress.org\/plugins\/media-sync\/<\/a><\/p>\n\n\n\n<p>If you have installed and activated the plugin, read the manual carefully. There are 3 stettings, you should take in account:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>php <code>max_execution_time<\/code> in your php.ini file.<br>You might get an error like this:<br><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"51\" class=\"wp-image-85\" style=\"width: 300px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-122220-image.png\" alt=\"\"><br>if you have a to small value on it. I set mine to 240 seconds (default: 30 seconds).<\/li><li>disable sorting by date<br>The media library sorts files by default using the upload date. We don&#8217;t want WP to mess up our NC structure, so we disable it:<br><img loading=\"lazy\" decoding=\"async\" width=\"629\" height=\"354\" class=\"wp-image-89\" style=\"width: 600px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114801-image.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114801-image.png 629w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114801-image-300x169.png 300w\" sizes=\"auto, (max-width: 629px) 100vw, 629px\" \/><\/li><li>Media Sync: show dry run option<br>In the settings of Media Sync there is an option to enable the &#8220;Dry Run Option&#8221;. Enable it, to prevent accidents and to be able to test things before running sharp. We are fiddling with WPs file handler, so be carefull:<br><img loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"476\" class=\"wp-image-94\" style=\"width: 600px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114741-image-1.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114741-image-1.png 765w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114741-image-1-300x187.png 300w\" sizes=\"auto, (max-width: 765px) 100vw, 765px\" \/><\/li><\/ol>\n\n\n\n<p>Now everything is set. Lets test, if and how it works.<br>The Plugin sets below the Media Library Menue:<br><img loading=\"lazy\" decoding=\"async\" width=\"158\" height=\"131\" class=\"wp-image-86\" style=\"width: 150px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114820-image.png\" alt=\"\"><br>First thing we need to do, is to run a scan on the folder:<br><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"377\" class=\"wp-image-87\" style=\"width: 600px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114833-image.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114833-image.png 538w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114833-image-300x210.png 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><br>The result will be shown at the bottom of the page:<br><img loading=\"lazy\" decoding=\"async\" width=\"416\" height=\"410\" class=\"wp-image-93\" style=\"width: 600px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114215-image.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114215-image.png 416w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-114215-image-300x296.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><br>From here on it is a little &#8220;try and error&#8221;. I checked all files, but for some reason, not all were imported. It even needed 2 times the trigger on the video until it showed up.<br>Nevertheless, it has to be mentioned, that the files are not moved into another folder. They stay, where they are. Disadvantage: the thumbnails are also stored in that folder:<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>root@derdapp003:\/var\/www\/wordpress_prod\/wp-content\/uploads# ll nextcloud\/test\ntotal 5184\n-rw-r--r-- 1 www-data www-data 3963036 Oct  5 09:39 'Nextcloud intro.mp4'\n-rw-r--r-- 1 www-data www-data   11272 Oct  5 12:47  Nextcloud-150x150.png\n-rw-r--r-- 1 www-data www-data   22384 Oct  5 12:47  Nextcloud-300x180.png\n-rw-r--r-- 1 www-data www-data   26488 Oct  5 12:47  Nextcloud-300x300.png\n-rw-r--r-- 1 www-data www-data   28282 Oct  5 12:47  Nextcloud-350x230.png\n-rw-r--r-- 1 www-data www-data   50598 Oct  5 09:43  Nextcloud.png\n-rw-r--r-- 1 www-data www-data   29599 Oct  5 12:48  NoThanksButWereBusy-150x150.png\n-rw-r--r-- 1 www-data www-data   60715 Oct  5 12:48  NoThanksButWereBusy-300x169.png\n-rw-r--r-- 1 www-data www-data   66845 Oct  5 12:49  NoThanksButWereBusy-300x180.png\n-rw-r--r-- 1 www-data www-data   96750 Oct  5 12:48  NoThanksButWereBusy-350x230.png\n-rw-r--r-- 1 www-data www-data  298424 Oct  5 12:48  NoThanksButWereBusy-768x433.png\n-rw-r--r-- 1 www-data www-data  348479 Oct  5 12:49  NoThanksButWereBusy-850x479.png\n-rw-r--r-- 1 www-data www-data  303078 Jul 18 19:57  NoThanksButWereBusy.png<\/code><\/pre>\n\n\n\n<p>So it might get a little confusing on the Nextcloud UI later on:<br><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"569\" class=\"wp-image-210\" style=\"width: 600px\" src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-014413-image.png\" alt=\"\" srcset=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-014413-image.png 703w, https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/20221005-014413-image-300x243.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/p>\n\n\n\n<p>And now for the great final: What about the video file?<br>Here it comes:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/wordpress.familie-lahme.de\/wp-content\/uploads\/nextcloud\/test\/Nextcloud intro.mp4\"><\/video><\/figure>\n\n\n\n<p>And this time it loads direct from the Nextcloud using the webdav mount on the wordpress server.<\/p>\n\n\n\n<p>Resume:<br>This is not the &#8220;best&#8221; Solution, but it is for free. There are other Plugins in the wild, that need to be licensed and sometimes the price only makes sense for those, who make money with their WP instance. I do not.<br>Another point to consider is speed. I run on a low budget hardware and performance is not my primary target. This solution creates some bottlenecks in the chain, that reduce loading time. I do not serve to thousands of followers or fans. I only put my 2cents to the swarm.<br>So if you join me on this, feel free to enhance.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I run WordPress on my own device at home. All the media files I am using and will be using are also hosted on a machine in my network using Nextcloud.If I want to use a media file in a post I need to upload the file from Nextcloud to the WordPress server, which makes&#8230;<\/p>\n","protected":false},"author":2,"featured_media":216,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[15,16,14,13],"class_list":["post-57","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-media-library","tag-nextcloud","tag-webdav","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":10,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/posts\/57\/revisions\/218"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/media\/216"}],"wp:attachment":[{"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.familie-lahme.de\/index.php\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}