Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter isay

    (@isay)

    Ok, alright I’ll try that..

    I might have several different “shopping rooms” but perhaps I can try this out with User Group / User Access Manager plugin…

    Regards,
    Mike

    Thread Starter isay

    (@isay)

    I got this to work finally! I made a “manual” forced upload of the attachment images…

    This is the code I added to the private function copy_attachment( $attachment_data, $post_id) function located in ThreeWP_Broadcast.php near the end just after wp_update_attachment_metadata( $attach_id, $attach_data ) and before the last row return $attach_id:

    /*
    			Start add by MS
    			Upload images to Amazon CDN
    		*/
    
    		if ( defined( 'W3TC_LIB_W3_DIR' ) ) {
    			require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
    			$w3_plugin_cdn =& w3_instance('W3_Plugin_CdnCommon');
    			$upload_info = w3_upload_info();
    
    			$local_file = $upload_dir['path'] . '/' . $attachment_data->filename_base();
    			$remote_file = ltrim($upload_dir['path'] . '/' . $attachment_data->filename_base(), '/');
    
    			// Remove "wp-content/blogs.dir/5/" from the image path in remote file
    			$remove_prefix_to_path = ltrim($upload_dir['basedir'], '/');
    			$remove_prefix_to_path = str_replace ( 'files', '' , $remove_prefix_to_path);
    			$remove_prefix_to_path = str_replace ( 'uploads', '' , $remove_prefix_to_path);
    			$remote_file = str_replace ( $remove_prefix_to_path, '' , $remote_file);
    
    			$all_image_sizes = get_intermediate_image_sizes();
    			if ($w3_plugin_cdn) {
    
    				// Add original size image
    				$files = array(
    					// local_file1	=> remote_file1,
    					$local_file 		=> $remote_file,
    					);
    
    				// Add all other sizes of images
    				$i = 0;
    				$all_files = $attachment_data->file_metadata();
    				foreach ($all_image_sizes as $size) {
    					$i++;
    					//echo '<p>File '.$i.': '.$all_files["sizes"][$size]["file"].'</p>';
    					if (count($all_files["sizes"][$size]["file"]) > 0)
    						$files[
    							str_replace (
    								$attachment_data->filename_base() ,
    								$all_files["sizes"][$size]["file"] ,
    								$local_file )
    						] = str_replace (
    										$attachment_data->filename_base() ,
    										$all_files["sizes"][$size]["file"] ,
    										$remote_file );
    
    				}
    
    		    $results = array();
    		    $w3_plugin_cdn->upload($files, false, $results);
    		    $response = array(
    		        'results' => $results
    		    );
    				/* //DEBUG
    				if ($post_id == 1374) {
    					echo '<p>response = ';
    					print_r($response);
    					echo '</p>';
    
    					echo '<p>files = ';
    					print_r($files);
    					echo '</p>';			
    
    					echo '<p>w3_plugin_cdn = ';
    					print_r($w3_plugin_cdn);
    					echo '</p>';
    
    				}
    				*/
    			}
    		}
    		/*
    			End add by MS
    		*/
    Thread Starter isay

    (@isay)

    How can I check if the original thumbnail is uploaded to CDN?

    Hi there flynsarmy!

    This is nearly exactly what I need to do, only I use the w3-total-cache plugin. I described my problem here.

    Any ideas how I do the equivalent of $attachment_data->post_custom['amazonS3_info'] in your code above?

    Thank you very much for your help!

    //Mike

    Thread Starter isay

    (@isay)

    I managed to figure this out…

    Basically I created a function which trigger on post save:

    add_action('save_post', array(&$this,'save_event'));
    
    function do_the_broadcast($post_id) {
    $_POST['post_type'] = 'event';
    $_POST['broadcast']['link'] = 'link';
    $_POST['broadcast']['taxonomies'] = 'taxonomies';
    $_POST['broadcast']['taxonomies_create'] = 'taxonomies_create';
    $_POST['broadcast']['custom_fields'] = 'custom_fields';
    $broadcast = new ThreeWP_Broadcast();
    remove_action('save_post', array(&$this,'save_event'));
    ..... //Do some updates to the post ....
    $broadcast->save_post( $post_id );
    add_action('save_post', array(&$this,'save_event'));
    }

    Could I define which target blogs to broadcast to this way?
    E.g. if ($taxonomy == 'x') $_POST['broadcast']['blogs'] = array('blog1', 'blog2', '...'); else $_POST['broadcast']['blogs'] = array('blog3', 'blog4', '...');

    Thread Starter isay

    (@isay)

    That’s great!
    Let me know if you’d want some help testing it.
    Cheers,
    Mike

    Thread Starter isay

    (@isay)

    Ok, the following worked to get the image:

    $images = get_option('taxonomy_image_plugin');
    echo wp_get_attachment_image( $images[$tax_term_id], 'medium' );

    Now I’m gonna figure out a way to update the image in a similar way…

    //Mike

    Thread Starter isay

    (@isay)

    Aha, great!
    …and the image ID corresponds to the ID in the posts table. So to get the url of the image I execute:

    SELECT  ID, guid
    FROM  wp_posts
    WHERE  ID =  '14536'
    AND  post_type =  'attachment'

    Ok, I will play around with this.

    Thanks!
    /Mike

    Thread Starter isay

    (@isay)

    Any hints on this one??

    If I am on the archives page and click on the link to page 2 it seems as though that the query information is lost and I am presented the general posts.php template…

    In other words, WP seem to forget that I was in the archive view…

    Any help is appreciated!

    //Mike

    I need the above functionality in a plugin which lists sub-taxonomies..

    Thank you for help!

    //Mike

    Any inputs in looping through the categories and outputing the thumbnails.

    e.g. something similar to:

    foreach ($terms as $s => $term) {
         // Print the term image
         echo $term->name;
    }

    Chhers,
    Mike

    Thread Starter isay

    (@isay)

    Ok, I posted my archives.php and pagination.php into pastebin….

    archive.php: https://pastebin.com/9gTbXBTH
    pagination.php: https://pastebin.com/fNpdguPe

    Thanks really much guys if you would take a look at this!

    I really appreciate it…

    //Mike

    Thread Starter isay

    (@isay)

    Still 404…

    Sorry, something fell off when I pasted into the post…
    my archives.php code says $all_posts_in_cat = new WP_Query($args); instead of just WP_Query($args);

    Thread Starter isay

    (@isay)

    Still the “ERROR 404 – NOT FOUND”…

    When reading about the WP_Query it’s a bit cryptic:

    Pagination Note: You should set get_query_var( ‘page’ ); if you want your query to work with pagination. Since WordPress 3.0.2, you do get_query_var( ‘page’ ) instead of get_query_var( ‘paged’ ). The pagination parameter ‘paged’ for WP_Query() remains the same.

    I’ve tried a few options but still get the 404…

Viewing 14 replies - 1 through 14 (of 14 total)