Write a function or plugin for WordPress

  • Tình trạng: Closed
  • Giải thưởng: $50
  • Các bài thi đã nhận: 1
  • Người chiến thắng: bowenac

Tóm tắt cuộc thi

Rebuilding a WordPress site, a community of 4000+ active authors. The previous version had a custom front-end upload script allowing authors to create posts. Every post has one image followed by some text. The images were uploaded into normal uploads/year/month folders, BUT they're not in the library. There are over 20,000 posts, every post contains a string like this:


a href="http://www.mysite.com/wp-content/themes/prologue/phpThumb/phpThumb.php?src=../../../../wp-content/uploads/2010/03/4b94f1e580cc119.jpg"


So the images are displayed by phpThumb. And I want to get rid of that. Here's what I need to do:

For every post of post_type post, grab its post_content. Extract the image file name string:

http://www.mysite.com/wp-content/themes/prologue/phpThumb/phpThumb.php?src=../../../../wp-content/uploads/2010/03/4b94f1e580cc119.jpg)

Then turn that string into the actual file's location by removing all phpThumb stuff in the middle, so it becomes

http://www.mysite.com/wp-content/uploads/2010/03/4b94f1e580cc119.jpg

Take this new string, and programmatically add that image to the library, so it would create a normal set of thumbnails in the same uploads/year/month directory

Attach the new library image to the post we're processing at the moment

Also set this new library image as a featured image for this same post

Repeat 20,000 times

Các kĩ năng yêu cầu

Phản hồi của người thuê

“@bowenac won the contest on 27 May 2014”

Hình ảnh hồ sơ xfilevw, United States.

Bảng thông báo công khai

  • bowenac
    bowenac
    • cách đây 9 năm

    Sounds to me like it would make more sense to fix the upload script to not use phpThumb... Send me a PM and I'm sure I can get this working how you want it working.

    • cách đây 9 năm
    1. bowenac
      bowenac
      • cách đây 9 năm

      Are you around wanted to mention which I am sure you have already done is to create a backup of your posts table before running the plugin etc.

      • cách đây 9 năm
    2. bowenac
      bowenac
      • cách đây 9 năm

      I just updated the plugin and changed the regex in case your first url is not an image. You mentioned it was but just incase, I am checking for the first http that contains an image extension.

      • cách đây 9 năm
  • bowenac
    bowenac
    • cách đây 9 năm

    Ok I got this working if you want to test it out. I tested it by inserting some test posts, and replcaed the url in the db with your url example. Then I tossed some images in the uploads folder without using wordpress so that they were not in the media manager. Then ran the plugin, it created the thumbs and they show up in the media manager, as well as using the correct updated url.

    • cách đây 9 năm
    1. xfilevw
      Chủ cuộc thi
      • cách đây 9 năm

      Great, looks like you're moving in a right direction, but let me clarify a bit further.
      Once the image is retrieved from the uploads folder and added to the library (you've done that), I want it REMOVED from the post content. Instead, it should be ATTACHED to the post (just update the parent = post ID), and set as FEATURED for this post.
      Also, consider that if the plugin loops through the posts table, it will likely timeout, because there are 20,000+ posts, so we need to handle that somehow as well.

      • cách đây 9 năm
    2. xfilevw
      Chủ cuộc thi
      • cách đây 9 năm

      I can't post the HTML that needs to be removed from post (problem here with this form), but there's a pattern.

      • cách đây 9 năm

Xem thêm bình luận

Làm thế nào để bắt đầu với cuộc thi

  • Đăng cuộc thi của bạn

    Đăng cuộc thi của bạn Nhanh chóng và dễ dàng

  • Nhận được vô số bài dự thi

    Nhận được vô số Bài dự thi Từ khắp nơi trên thế giới

  • Trao giải cho bài thi xuất sắc nhất

    Trao giải cho bài thi xuất sắc nhất Download File - Đơn giản!

Đăng cuộc thi ngay hoặc tham gia với chúng tôi ngay hôm nay!