Results 1 to 7 of 7

Thread: Not sure if this is the right place, but WP help.

Threaded View

  1. #1
    Lmp's Avatar
    Joined
    Dec 2011
    Posts
    1,341
    Userbars
    9
    Thanks
    269
    Thanked
    624/198
    DL/UL
    53/0
    Mentioned
    323 times
    Time Online
    178d 13h 12m
    Avg. Time Online
    1h 1m

    Not sure if this is the right place, but WP help.

    So I have this code which is part of a CSV Importer:
    Code:
    public function saveImageWithUrl($image)
    	{
    		$attach_id = false;
    		$upload_dir = wp_upload_dir();
    		//get data
    		$image_data = @file_get_contents($image);
    
    		//get the filename
    		$filename = basename($image);
    
    		//create the dir or take the current one
    		if (wp_mkdir_p($upload_dir['path'])) {
    			$file = $upload_dir['path'] . '/' . $filename;
    		} else {
    			$file = $upload_dir['basedir'] . '/' . $filename;
    		}
    Right now, when the importer imports a image, it names the image based on it`s URL (E.g imageshack.us/a/img585/4739/8jp6.png, would mean it would name it 8jp6.png).
    However, I want the importer to name it based on it`s WP Post Title. I tried to manipulate the code but failed, if anyone can help, it`d be much appreciated, thanks!
    Last edited by Lmp; 10-15-2013 at 01:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •