Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112996

drewdogcomputers on "Importing a huge amount of images, any good ideas? (very challenging)"

$
0
0

Alright, I have over 150k pics weighing in ~6GB. They have generic names from the camera, have some EXIF data like the date the pic was taken on, all the pics are in nested folders (the first few years are in inconsistent formats >.< I didn't make this mess) and the structure is roughly
(school year range)\(season)\(gender)_(sport)\(team1)_(team2)
for example
2012-2013\2012_Winter_Sports\Boys_Basketball\Carlton_SouthRidge
and I have a script I wrote to import the posts from a cutenews(1.5) flat file into wordpress (categories too, I'll post the script when I'm finished).

Everything works great, but the images from cutenews are imbedded inline in the post via html
for example
<img alt="" width="498" height="332" src="/cutenews/data/upimages/image/2012-2013/Winter_Sports/DSC_2666.jpg" />
(no team names)

I want to import these pics into wordpress from these old posts and be able to have my users see them in wp, and also have new posts be a consistent structure with the old ones (but change the old structure to the new wp one, ya know?) and keep the formatting on the post (so the position and image size are the same)

So I have a few questions:

How (in php) can I parse the line:
<img alt="" width="498" height="332" src="/cutenews/data/upimages/image/2012-2013/Winter_Sports/DSC_2666.jpg" />
and replace it with a wp shortcode pointing to the image, after imported into wp?
like:

now, the part that makes this hard is I want to import the folders
(school year range)\(season)\(gender)_(sport)\(team1)_(team2)
into gallerys (like nggallery or something) so I can replace the link in the post that points to the folder\index.php script which displays all the pics in the directory with the shortcode for the gallery? An example of the link is
<p style="text-align: center"><a href="http://site/gallery/2012-2013/2012_Winter_Sports/Boys_Basketball/(team1)_(team2)"><span style="font-size: medium">For additional photos click here to view our complete photo gallery</span></a></p>
it would be awesome if I could retain the names of the folders as data for the gallery too.

One thing I haven't been able to figure out that is greatly slowing me down is how to take the href out of the above code but keep all the other stuff and extract the info from the href to use to import the folder to a gallery and replace the href with the shortcode of the imported gallery.
its more a php question than a wordpress one, just a snippet of code showing how to extract the info and replace it with a new string generated using said info would be incredibly helpful

Now I'm not asking for someone to write me a script (unless you want to :D) however some pseudo code for a strategy of how to tackle this would be so helpful.


Viewing all articles
Browse latest Browse all 112996

Trending Articles