Jump to content

cjboston

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Posts posted by cjboston

  1. here is the code can you elaborate?

    <?php
    
    function put_image_here( $args = array() ) {
    
    $defaults = array(
    	'custom_key' => array( 'Thumbnail', 'thumbnail' ),
    	'post_id' => false, // Build functionality in later
    	'attachment' => true,
    	'default_size' => 'thumbnail',
    	'default_image' => true,
                   'order_of_image' => 1,
    	'link_to_post' => true,
    	'image_class' => false,
    	'image_scan' => true,
    	'width' => true,
    	'height' => true,
    	'format' => 'img',
    	'echo' => true
    );
    
    $args = apply_filters( 'put_image_here_args', $args );
    
    $args = wp_parse_args( $args, $defaults );
    
    extract( $args );
    
    if ( !is_array( $custom_key ) ) :
    	$custom_key = str_replace( ' ', '', $custom_key) ;
    	$custom_key = str_replace( array( '+' ), ',', $custom_key );
    	$custom_key = explode( ',', $custom_key );
    	$args['custom_key'] = $custom_key;
    endif;
    
    if ( $custom_key && $custom_key !== 'false' && $custom_key !== '0' )
    	$image = image_by_custom_field( $args );
    
    if ( !$image && $attachment && $attachment !== 'false' && $attachment !== '0' )
    	$image = image_by_attachment( $args );
    
    if ( !$image && $image_scan )
    	$image = image_by_scan( $args );
    
    if (!$image && $default_image )
    	$image = image_by_default( $args );
    
    if ( $image )
    	$image = display_the_image( $args, $image );
    
    else
    	$image = '<!-- No images were added to this post. -->';
    
    if ( $echo && $echo !== 'false' && $echo !== '0' && $format !== 'array' )
    	echo $image;
    else
    	return $image;
    }
    
    /**
    * Calls images by custom field key
    * Script loops through multiple custom field keys
    * If that particular key is found, $image is set and the loop breaks
    * If an image is found, it is returned
    *
    * @since 0.3
    * @param array $args
    * @return array|bool
    */
    function image_by_custom_field( $args = array() ) {
    
    extract( $args );
    
    if( !$post_id )
    	global $post;
    
    if( isset( $custom_key ) ) :
    	foreach ( $custom_key as $custom ) :
    		$image = get_post_meta( $post->ID, $custom, true );
    		if ( $image ) :
    			break;
    		endif;
    	endforeach;
    	if ( !$image ) :
    		return false;
    	endif;
    endif;
    
    return array( 'image' => $image );
    }
    
    /**
    * Check for attachment images
    * Uses get_children() to check if the post has images attached
    * If image attachments are found, loop through each
    * The loop only breaks once $order_of_image is reached
    *
    * @since 0.3
    * @param array $args
    * @return array|bool
    */
    function image_by_attachment( $args = array() ) {
    
    extract( $args );
    
    if ( !$post_id )
    	global $post;
    
    /*
    * Get attachments
    */
    $attachments = get_children( array( 'post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
    
    if ( empty( $attachments ) )
    	return false;
    
    foreach ( $attachments as $id => $attachment ) :
    	$i++;
    	if ( $i == $order_of_image ) :
    		$image = wp_get_attachment_image_src( $id, $default_size );
    		$image = $image[0];
    		break;
    	endif;
    endforeach;
    
    return array( 'image' => $image );
    }
    
    /**
    * Scans the post for images within the content
    * Not called by default with put_image_here()
    * Shouldn't use if using large images within posts, better to use the other options
    *
    * @since 0.3
    * @param array $args
    * @return array|bool
    */
    function image_by_scan( $args = array() ) {
    
    if ( !$post_id )
    	global $post;
    
    preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches );
    
    if ( isset( $matches ) ) $image = $matches[1][0];
    
    if ( $matches[1][0] )
    	return array( 'image' => $image );
    else
    	return false;
    }
    
    /**
    * Used for setting a default image
    * Not used with put_image_here() by default
    *
    * @param array $args
    * @return array
    */
    function image_by_default( $args = array() ) {
    
    extract( $args );
    
    $image = $default_image;
    
    return array( 'image' => $image );
    }
    
    /**
    * Formats an image with appropriate alt text and class
    * Adds a link to the post if argument is set
    * Should only be called if there is an image to display, but will handle it if not
    *
    * @since 0.1
    * @param array $args
    * @param array $arr Array of image info ($image, $classes, $alt, $caption)
    * @return string $image Formatted image (w/link to post if the option is set)
    */
    function display_the_image( $args = array(), $arr = false ) {
    global $post;
    
    extract( $arr );
    
    if ( !$image )
    	return;
    
    extract( $args );
    
    if ( $width )
    	$width = ' width="' . $width . '"';
    if ( $height )
    	$height = ' height="' . $height . '"';
    
    $img = $image;
    
    if ( is_array( $custom_key ) ) :
    	foreach ( $custom_key as $key ) :
    		if ( $key !== 'false' && $key !== '0' ) :
    			$classes[] = str_replace( ' ', '-', strtolower( $key ) );
    		endif;
    	endforeach;
    endif;
    
    $classes[] = $default_size;
    $classes[] = $image_class;
    
    $class = join( ' ', $classes );
    
    $image = '';
    
    if ( $format == 'array' ) :
    	$image = array(
    		'url' => $img,
    		'alt' => the_title_attribute( 'echo=0' ),
    		'class' => $class,
    		'link' => get_permalink( $post->ID ),
    	);
    	return $image;
    endif;
    
    if ( $link_to_post )
    	$image .= '<a href="' . get_permalink( $post->ID ) . '" title="' . the_title_attribute( 'echo=0' ) . '">';
    
    $image .= '<img src="' . $img . '" alt="' . the_title_attribute( 'echo=0' ) . '" class="' . $class . '"' . $width . $height . ' />';
    
    if ( $link_to_post )
    	$image .= '</a>';
    
    return $image;
    }
    
    /**
    * Use put_image_here() instead
    *
    * @since 0.1
    * @deprecated 0.3
    */
    function put_image_here_link( $deprecated = '', $deprecated_2 = '', $deprecated_3 = '' ) {
    put_image_here();
    }
    
    ?>[.code]

  2. I am using a script that imports images using an array of calls to check for various ifs. the call to the script is <?php import_my_pic( array('default_image' => 'actual default image url', 'default_size' => 'thumbnail', 'width' => '60', 'height' => '60' ) ); ?>

    I have it working fine but I want to call the default image from a folder so the older pages don't all have the same image,i have php script that does that

    <?php import_my_pic( array('default_image' => ' include('random.php')', 'default_size' => 'thumbnail', 'width' => '60', 'height' => '60' ) ); ?>

    can this be done?

  3. i have rss feed display script.it worked fine in a mysql 4.1. when i tried to upload the dump to a 4.0 it gave me the error :
    [color=blue]#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARSET=latin1' at line 4[/color]
    How do i retro fit the dump

    [color=red]--------------------------------------------------------

    --
    -- Table structure for table `config`
    --

    CREATE TABLE `config` (
      `name` varchar(30) NOT NULL default '',
      `value` text NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `config`
    --


    -- --------------------------------------------------------

    --
    -- Table structure for table `feed`
    --

    CREATE TABLE `feed` (
      `feedid` bigint(20) NOT NULL auto_increment,
      `uid` varchar(20) NOT NULL default '',
      `tplindex` bigint(3) NOT NULL default '1',
      `url` text NOT NULL,
      PRIMARY KEY  (`feedid`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

    --
    -- Dumping data for table `feed`
    --

    INSERT INTO `feed` VALUES (1, 'admin', 1, 'http://news.google.com/news?hl=en&ned=us&q=outer+space&ie=UTF-8&output=rss');

    -- --------------------------------------------------------

    --
    -- Table structure for table `tpl`
    --

    CREATE TABLE `tpl` (
      `tplindex` bigint(20) NOT NULL auto_increment,
      `name` varchar(30) NOT NULL default '',
      `fname` varchar(100) NOT NULL default '',
      PRIMARY KEY  (`tplindex`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

    --
    -- Dumping data for table `tpl`
    --

    INSERT INTO `tpl` VALUES (1, 'Default Skin', 'default.tpl');

    -- --------------------------------------------------------

    --
    -- Table structure for table `user`
    --

    CREATE TABLE `user` (
      `uid` varchar(20) NOT NULL default '',
      `upass` varchar(20) NOT NULL default '',
      `email` varchar(255) NOT NULL default '',
      PRIMARY KEY  (`email`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `user`
    --

    INSERT INTO `user` VALUES ('admin', 'admin', 'adMIN@gmarketingsolutions.com');
    INSERT INTO `user` VALUES ('saire', 'a', 'biznis@yahoo.com');[/color]

    Thanks,
        CJ Boston
        [url=http://www.profitextreme.biz/][color=purple]web site promotion[/color][/url]
  4. I was trying to use a squeeze page and all of my sites (on the same server) give me a mail diabled for security. I checked the php info and the disable_function value is mail. How does this get corrected?
    P.S.
    I Know nothing about php
    Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.