Forum Replies Created

Viewing 4 replies - 76 through 79 (of 79 total)
  • Thread Starter RBX

    (@rbx)

    The only place I could find absolute paths was table of plugin EWWW Image Optimizer, which isn’t even active because exec() is disabled on server.

    The other places I found image paths were in table postmeta with image data stored for meta keys _wp_attached_file, _wp_attachment_metadata, _wp_attachment_image_alt and in posts table with post type attachment.

    Thread Starter RBX

    (@rbx)

    It is still being built on localhost. The theme is listify and I’m displaying advertisements using the slider in the listify advertisement widget.

    I currently have applied this quick dirty fix in listify_get_attachment_id_by_url() in Listify 1.0.5.

    $prefix = '/uploads/';
    $prefix_length = strlen($prefix);
    
    $match = substr($parsed_url[1], $prefix_length);
    $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_wp_attached_file' AND meta_value RLIKE %s;", $match ) );

    My theme contains support for featured image and gallery. I found following in my theme

    add_action( 'job_manager_update_job_data', array( $this, 'save_featured_image' ), 10, 2 );
    add_action( 'job_manager_update_job_data', array( $this, 'save_gallery_images' ), 10, 2 );

    and using debugger, I found that these are called, but the following functions contained in same file never get called, thus even though the images are uploaded and attached to listing, they aren’t set as featured/listing gallery images.

    public function save_featured_image( $job_id, $values ) {
    	$attachment_url = $values[ 'job' ][ 'featured_image' ];
    	$attach_id = listify_get_attachment_id_by_url( $attachment_url );
    
    	if ( $attach_id != get_post_thumbnail_id( $job_id ) ) {
    		set_post_thumbnail( $job_id, $attach_id );
    	} elseif( '' == $attachment_url && has_post_thumbnail( $job_id ) ) {
    		delete_post_thumbnail( $job_id );
    	}
    }
    
    public function save_gallery_images( $job_id, $values ) {
    	$images = $values[ 'job' ][ 'gallery_images' ];
    
    	if ( ! isset( $images ) || empty( $images ) ) {
    		return;
    	}
    
    	$gallery = array();
    
    	foreach ( $images as $image ) {
    		$gallery[] = listify_get_attachment_id_by_url( $image );
    	}
    
    	$gallery = implode( ',', $gallery );
    
    	$shortcode = '[gallery ids=' . $gallery . ']';
    
    	update_post_meta( $job_id, '_gallery', $shortcode );
    }

    Edit: Nevermind, the function listify_get_attachment_id_by_url doesn’t seem to be working. Looks like I need to debug it myself or contact Astoundify.

Viewing 4 replies - 76 through 79 (of 79 total)