How to Increase the Maximum File Upload Size in WordPress?

maximum file upload size in WordPress.

Media File Size Limit

Note: This is an intermediate level tutorial. It may not work with some shared hosts in which case you would have to ask your hosting service provider for support. We use HostGator, and they are more than helpful when it comes to issues like this.

1: Theme Functions File

There are cases where we have seen that just by adding the following code in the theme function’s file, you can increase the upload size:

1 @ini_set( 'upload_max_size' , '64M' );
2 @ini_set( 'post_max_size', '64M');
3 @ini_set( 'max_execution_time', '300' );

2. Create or Edit an existing PHP.INI file

In most cases if you are on a shared host, you will not see a php.ini file in your directory. If you do not see one, then create a file called php.ini and upload it in the root folder. In that file add the following code:

1 upload_max_filesize = 64M
2 post_max_size = 64M
3 max_execution_time = 300

This method is reported to work for many users. Remember if 64 doesn’t work. Try 10MB (sometimes that work).

3. htaccess Method

Some people have tried using the htaccess method where by modifying the .htaccess file in the root directory, you can increase the maximum upload size in WordPress. Open or create the .htaccess file in the root folder and add the following code:

1 php_value upload_max_filesize 64M
2 php_value post_max_size 64M
3 php_value max_execution_time 300
4 php_value max_input_time 300

Again, it is important that we emphasize that if you are on a shared hosting package, these techniques may not work. In that case, you would have to contact your web hosting provider to increase the limit for you. Some hosts completely turn down their users. We recommend that you use HostGator. Their support folks are very helpful in these situations.

how to control youtube video width/height thumb with wordpress?

/********************************************************************
show any video (control width/height)
********************************************************************/
define(“YOUTUBE_TARGET”, “<object width=\”###WIDTH###\” height=\”###HEIGHT###\”><param name=\”movie\” value=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\”></param><param name=\”allowFullScreen\” value=\”true\”></param><param name=\”allowscriptaccess\” value=\”always\”></param><embed src=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\” type=\”application/x-shockwave-flash\” allowscriptaccess=\”always\” allowfullscreen=\”true\” width=\”###WIDTH###\” height=\”###HEIGHT###\”></embed></object>”);
define(“YOUTUBE_IMAGE”, “<img src=\”http://img.youtube.com/vi/###URL###/hqdefault.jpg\” width=\”###WIDTH###\” height=\”###HEIGHT###\”/>”);

function show_video($args,$width,$height,$showtitle,$showimage) {
//’cat=37&posts_per_page=1&orderby=date&order=Desc’
query_posts($args);
if( have_posts() ) {
while( have_posts() ) {
the_post();

$filtered_content = str_replace(‘<p>’,”,get_the_content());
$filtered_content = str_replace(‘</p>’,”,$filtered_content);
$filtered_content=rtrim($filtered_content, “]”);
$filtered_content=ltrim($filtered_content, “[“);
if(!$showimage)
$output = YOUTUBE_TARGET;
else
$output = YOUTUBE_IMAGE;

$output = str_replace(“###URL###”, $filtered_content, $output);
$output = str_replace(“###WIDTH###”,$width, $output);
$output = str_replace(“###HEIGHT###”, $height, $output);
print     $output;

if($showtitle){
print ‘<a href=”‘;
the_permalink();
print ‘” title=”‘;
print the_title();
print ‘”>’;
print the_title_limit(220, ”);
print ‘</a>’;
}
}}
wp_reset_query();
}

How to get thumbnail of YouTube video link using YouTube API?

Each YouTube video has 4 generated images. They are predictably formatted as follows:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg

For the high quality version of the thumbnail use a url similar to this:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

Alternatively, you can use the YouTube API to get thumbnail images

show youtube vedio by width,heigh

/********************************************************************
show any video (control width/height)
********************************************************************/
define(“YOUTUBE_WIDTH”, 310); // default width
define(“YOUTUBE_HEIGHT”, 250); // default height
define(“YOUTUBE_REGEXP”, “/\[youtube ([[:print:]]+)\]/”);
define(“YOUTUBE_TARGET”, “<object width=\”###WIDTH###\” height=\”###HEIGHT###\”><param name=\”movie\” value=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\”></param><param name=\”allowFullScreen\” value=\”true\”></param><param name=\”allowscriptaccess\” value=\”always\”></param><embed src=\”http://www.youtube.com/v/###URL###?fs=1&amp;hl=en_US\” type=\”application/x-shockwave-flash\” allowscriptaccess=\”always\” allowfullscreen=\”true\” width=\”###WIDTH###\” height=\”###HEIGHT###\”></embed></object>”);

function youtube_plugin_callback($match)
{     //    print $match;
$tag_parts = explode(” “, rtrim($match[0], “]”));
$output = YOUTUBE_TARGET;

$output = str_replace(“###URL###”, $tag_parts[1], $output);
if (count($tag_parts) > 2) {
if ($tag_parts[2] == 0) {
$output = str_replace(“###WIDTH###”, YOUTUBE_WIDTH, $output);
} else {
$output = str_replace(“###WIDTH###”, $tag_parts[2], $output);
}
if ($tag_parts[3] == 0) {
$output = str_replace(“###HEIGHT###”, YOUTUBE_HEIGHT, $output);
} else {
$output = str_replace(“###HEIGHT###”, $tag_parts[3], $output);
}
} else {
$output = str_replace(“###WIDTH###”, YOUTUBE_WIDTH, $output);
$output = str_replace(“###HEIGHT###”, YOUTUBE_HEIGHT, $output);
}
return ($output);
}

function youtube_plugin($content)
{
return (preg_replace_callback(YOUTUBE_REGEXP, ‘youtube_plugin_callback’, $content));
}

function show_video() {
global $sources;
query_posts( ‘cat=37&posts_per_page=1&orderby=date&order=Desc’ );
if( have_posts() ) {
while( have_posts() ) {
the_post();
print the_title();
//get_the_content();
$filtered_content = str_replace(‘<p>’,”,get_the_content());
$filtered_content = str_replace(‘</p>’,”,$filtered_content);
//print $filtered_content;
print youtube_plugin($filtered_content);
}}wp_reset_query();
}

add breadcrumbs for wordpress

function dimox_breadcrumbs() {

$delimiter = ‘&raquo;’;
$home = ‘الرئيسية’; // text for the ‘Home’ link
$before = ‘<span>’; // tag before the current crumb
$after = ‘</span>’; // tag after the current crumb
$you=”انت هنا فى “;
echo ‘<div id=”crumbs”><span>’.$you.'</span>’;

global $post;
$homeLink = get_bloginfo(‘url’);
echo ‘<a href=”‘ . $homeLink . ‘”>’.$home.'</a> ‘ . $delimiter . ‘ ‘;

if ( !is_home() && !is_front_page() || is_paged() ) {

if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ‘ ‘ . $delimiter . ‘ ‘));
echo $before . ‘Archive by category “‘ . single_cat_title(”, false) . ‘”‘ . $after;

} elseif ( is_day() ) {
echo ‘<a href=”‘ . get_year_link(get_the_time(‘Y’)) . ‘”>’ . get_the_time(‘Y’) . ‘</a> ‘ . $delimiter . ‘ ‘;
echo ‘<a href=”‘ . get_month_link(get_the_time(‘Y’),get_the_time(‘m’)) . ‘”>’ . get_the_time(‘F’) . ‘</a> ‘ . $delimiter . ‘ ‘;
echo $before . get_the_time(‘d’) . $after;

} elseif ( is_month() ) {
echo ‘<a href=”‘ . get_year_link(get_the_time(‘Y’)) . ‘”>’ . get_the_time(‘Y’) . ‘</a> ‘ . $delimiter . ‘ ‘;
echo $before . get_the_time(‘F’) . $after;

} elseif ( is_year() ) {
echo $before . get_the_time(‘Y’) . $after;

} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != ‘post’ ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo ‘<a href=”‘ . $homeLink . ‘/’ . $slug[‘slug’] . ‘/”>’ . $post_type->labels->singular_name . ‘</a> ‘ . $delimiter . ‘ ‘;
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ‘ ‘ . $delimiter . ‘ ‘);
echo $before . get_the_title() . $after;
}

} elseif ( !is_single() && !is_page() && get_post_type() != ‘post’ && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;

} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ‘ ‘ . $delimiter . ‘ ‘);
echo ‘<a href=”‘ . get_permalink($parent) . ‘”>’ . $parent->post_title . ‘</a> ‘ . $delimiter . ‘ ‘;
echo $before . get_the_title() . $after;

} elseif ( is_page() && !$post->post_parent ) {
echo $before . get_the_title() . $after;

} elseif ( is_page() && $post->post_parent ) {
$parent_id  = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = ‘<a href=”‘ . get_permalink($page->ID) . ‘”>’ . get_the_title($page->ID) . ‘</a>’;
$parent_id  = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo $crumb . ‘ ‘ . $delimiter . ‘ ‘;
echo $before . get_the_title() . $after;

} elseif ( is_search() ) {
echo $before . ‘Search results for “‘ . get_search_query() . ‘”‘ . $after;

} elseif ( is_tag() ) {
echo $before . ‘Posts tagged “‘ . single_tag_title(”, false) . ‘”‘ . $after;

} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before . ‘Articles posted by ‘ . $userdata->display_name . $after;

} elseif ( is_404() ) {
echo $before . ‘Error 404’ . $after;
}

if ( get_query_var(‘paged’) ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ‘ (‘;
echo __(‘Page’) . ‘ ‘ . get_query_var(‘paged’);
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ‘)’;
}

}
echo ‘</div>’;

} // end dimox_breadcrumbs()

how to add subscripe to your blog at wordpress?

<form action=”?page_id=22″ method=”post”>
<input type=”hidden” value=”s” name=”na”>
<input type=”hidden” value=”widget” name=”nr”>
<input type=”text” name=”ne” id=”Email” >
<input type=”button” value=”إشترك”
onclick=”if(this.form.ne.value==”) alert(‘ادخل البريد الالكترونى’); else {if(validateEmail(this.form.ne.value)) this.form.submit();
else alert(‘ادخل بريد الكنرونى بطريه صحيحة’);}” />
</form>

 

function validateEmail(elementValue){
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailPattern.test(elementValue);
}