Moving images to v1e.com
Closed this issue · 5 comments
Forum for reference: https://forum.v1e.com/t/website-refresh/34933/90?u=jeffeb3
We have a bunch of images linked in the form:
tools/milling-basics.md:227:![!pic](https://www.v1engineering.com/wp-content/uploads/2018/06/start.jpg){: loading=lazy width="400"}
We need to move those to the new server (at the new URL). The docs should point to something at the new v1e.com site for these images.
I'll use this space to document the steps we're taking, and reference back to this for the final PR.
I found the list of images with this bash command:
grep -rn wp-content > v1_images.txt
That created a list of 580 lines with images linked from "wp-content". On closer inspection, those all look like valid images from the v1engineering website:
I created a python script to parse that list of images and download each image to a similar location on my local machine:
#!/usr/bin/python3
import os.path
import pathlib
import urllib.request
outdir='img/'
with open('v1_images.txt', 'r') as links:
for line in links:
# Find where the word "uploads/" ends
upload_char = line.find('uploads')+8
# Grab the text after that, until we reach a double quote or a close parenthesis
filename = line[upload_char:].strip().split(')')[0].split('"')[0].strip()
# Use os.path to find the folder name
foldername = os.path.dirname(filename)
# Get the original URL by getting everything until a close parenthesis, and then everything
# back to the open parenthesis, and then cut off anything after the double quote.
original_url = line.split(')')[0].split('(')[-1].split('"')[0].strip()
# Make the directory (should be OS independent. It works in Linux)
pathlib.Path(outdir+foldername).mkdir(parents=True, exist_ok=True)
# Download the url to the output folder
print('downloading: ', url)
urllib.request.urlretrieve(url, filename=outdir+filename)
The result is a folder img
with the images downloaded. I zipped these images up, and I will email them to you, @V1EngineeringInc.
This is what I think the next steps are:
- You can upload the images from the zip file I am sending you somewhere on v1e.com. Ideally, in the same or similar folder structure
- There will be some new url. Instead of
https://www.v1engineering.com/wp-content/uploads/2018/06/start.jpg
, it will behttps://v1e.com/media/2018/06/start.jpg
or something like that. - I can write a sed script to replace all the instances of
www.v1engineering.com/wp-content/uploads/
withv1e.com/media/
and run it in the local copy of the docs. That should change all the markdown files at once. - I will commit and make a PR. The PR merging should be fine, as long as all the files are in the right place, because they followed the same pattern.
Thank you!