Is it possible to ask WordPress to look in all ‘uploads’ folder and not just a specific one? As you’ll see from the script below, it’s looking for images with the same name and a specific prefix…
'wp-content/uploads/2012/01/'
I want it to be something like…
'wp-content/uploads/*/*/'
as the way it is, it’s not working for anything else, for example if the image file has the prefix…
'wp-content/uploads/2012/02/'
My script is…
$(document).ready(function(){
$(".gigthumb").each(function() {
var a = $(this).parent();
a.attr("href", a.prev().attr("href"));
});
$('img.gigthumb').each(function(){
var foo = $(this).parent().attr('href').split('/').pop();
$(this).attr('src','wp-content/uploads/2012/01/' + foo + '.jpg');
});
$('img.gigthumb').error(function() {
$(this).attr('src','wp-content/plugins/gigpress/images/placeholder.gif');
});
Hope this makes sense. Quite difficult to explain the issue.
Doing this would be very cumbersome and terribly slow. You would have to serve all the possible paths from server side, and then walk through them using Ajax requests or something. It’s not a good solution.
The problem should be solvable more easily by changing the way WordPress organizes your uploads. The setting is in Settings -> Media:
I don’t know, however, what happens if you do this on an existing install that already has uploads. You may have to reorganize/re-upload all your posts’ content to be able to use this (I’m pretty sure WP won’t automatically re-organize.) Use at your own risk and make backups.