Showing posts with label Codes. Show all posts
Showing posts with label Codes. Show all posts

We recommend you to see related post to find more which you may don't have or may don't know about that. For more information just post in comment box below or feel free to contact us personaly
In theme folder, paste the following code to the functions.php file. If you don not have a functions.php file then first create this one.
<?php
function dropdown_tag_cloud( $args = '' ) {
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => ''
);
$args = wp_parse_args( $args, $defaults );
$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags
if ( empty($tags) )
return;
$return = dropdown_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
if ( is_wp_error( $return ) )
return false;
else
echo apply_filters( 'dropdown_tag_cloud', $return, $args );
}
function dropdown_generate_tag_cloud( $tags, $args = '' ) {
global $wp_rewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
);
$args = wp_parse_args( $args, $defaults );
extract($args);
if ( !$tags )
return;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
if ( is_wp_error( $tag_links[$tag->name] ) )
return $tag_links[$tag->name];
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min($counts);
$spread = max($counts) - $min_count;
if ( $spread <= 0 )
$spread = 1;
$font_spread = $largest - $smallest;
if ( $font_spread <= 0 )
$font_spread = 1;
$font_step = $font_spread / $spread;
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' == $orderby )
uksort($counts, 'strnatcasecmp');
else
asort($counts);
if ( 'DESC' == $order )
$counts = array_reverse( $counts, true );
$a = array();
$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
foreach ( $counts as $tag => $count ) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(' ', ' ', wp_specialchars( $tag ));
$a[] = "\t<option value='$tag_link'>$tag ($count)</option>";
}
switch ( $format ) :
case 'array' :
$return =& $a;
break;
case 'list' :
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
$return .= join("</li>\n\t<li>", $a);
$return .= "</li>\n</ul>\n";
break;
default :
$return = join("\n", $a);
break;
endswitch;
return apply_filters( 'dropdown_generate_tag_cloud', $return, $tags, $args );
}
?>
Now open the file where you want the list to be displayed and paste the following code:
<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Tags</option>
<?php dropdown_tag_cloud('number=0&order=asc'); ?>
</select>
You are done! Thank you.
Here is the CSS code which helps you to flip the images. For example having only one graphic for an "arrow", but flipping it around to point in different directions.
Question related to this topic:
Can this trick be applied to background images?
The answer is Yes! It can be applied to background images.
Actually it can be applied to background images and it works fine with the following:
-Fire Fox
-Chrome
-IE
The problem related with IE is, When you will use the IE it will show the “ActiveX” bar at top of your page and asks you to allow the Blocked Content or otherwise it will only show the none-flipped background image. I know this is very annoying but this what it is.
So When it asks to allow you simply allow it.
Demo:
Unflipped Image:
Flipped Image:
Now here Comes the Code:
***---CSS---***
img {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
This CSS trick is amzanig and i am sure you will like it. Just another coolest thing with CSS3 animations. If you are worried about super deep browser support, use a GIF file.
Well, I guess you are using a good browser. If i am wrong then please uninstall it and install and use a good/better one. Thank You!
***---HTML---***<div class="loader"><span></span><span></span><span></span></div>
***---CSS---***.loader {text-align: center;}.loader span {display: inline-block;vertical-align: middle;width: 10px;height: 10px;margin: 50px auto;background: black;border-radius: 50px;-webkit-animation: loader 0.9s infinite alternate;-moz-animation: loader 0.9s infinite alternate;}.loader span:nth-of-type(2) {-webkit-animation-delay: 0.3s;-moz-animation-delay: 0.3s;}.loader span:nth-of-type(3) {-webkit-animation-delay: 0.6s;-moz-animation-delay: 0.6s;}@-webkit-keyframes loader {0% {width: 10px;height: 10px;opacity: 0.9;-webkit-transform: translateY(0);}100% {width: 24px;height: 24px;opacity: 0.1;-webkit-transform: translateY(-21px);}}@-moz-keyframes loader {0% {width: 10px;height: 10px;opacity: 0.9;-moz-transform: translateY(0);}100% {width: 24px;height: 24px;opacity: 0.1;-moz-transform: translateY(-21px);}}
Reference URL
Here are some usefull techniques and guidance of CSS and one HTML code for Absolute Center (Vertical & Horizontal) An Image.
Caution:
The problem here is that if you will re-size the browser you cannot scroll to the top. For example: if you have a menu on top you cant view it.
CSS background-image Technique:
html {width:100%;height:100%;background:url(logo.png) center center no-repeat;}
Table technique:
***---CSS----***html, body, #wrapper {height:100%;width: 100%;margin: 0;padding: 0;border: 0;}#wrapper td {vertical-align: middle;text-align: center;}
***---HTML---***<html><body><table id="wrapper"><tr><td><img src="logo.png" alt="" /></td></tr></table></body></html>CSS + Inline Image Technique:img {position: absolute;top: 50%;left: 50%;width: 500px;height: 500px;margin-top: -250px; /* Half the height */margin-left: -250px; /* Half the width */}
It is also possible to do this using div’s and CSS:
<div class="contendor" style="border: 1px solid green; margin: 0; padding: 0; display: table"><div class="contendor-secundario" style="border: 1px solid yellow; margin: 0; padding: 0; display: table-row"><div class="columna1" style="border: 1px solid red; margin: 0pt; padding: 0pt; vertical-align: middle; display: table-cell">columna uno</div><div class="columna2" style="border: 1px solid blue; margin: 0; padding: 0; display: table-cell">column two,which is quite higher than the previous one,also, we can make even higherand column 1 is no longer centered</div></div></div>
![]() |
Photo Source: www.iconfinder.com |
#content {position: absolute;top: -9999px;left: -9999px;}
'' Removes an item from the page, without affecting page flow or causing scrollbars. Much better than display: none; or even visibility: hidden; ''
Caution:
This is bad practice! as Google will simply remove your site from their search results altogether. Google has stated time and time again thruough webmaster central for web designers NOT to position elements off the screen. If you are going to need to hide an element use the “display: none;” property, and not “display: hidden;”. If Google penalizes your site for hiding content they will notify you if you have a webmaster tools account, otherwise you may get no notice at all of a manual action taken against your site. If you are penalized, simply submit a request for reconsideration to Google, and explain why you are using the “display: none;” property and prove its for legitimate use, such as having the elements appear with alternate sizes depending on the resolution of the users screen, hence “media queries” in CSS.
For SEO purpose, be aware that this technique could lead you to be blacklisted. The same reason as above. You can hide a mnu item, stuff like that, but if you hide a div full of h1 and anchors just for SEO purpose, google may blacklist list you.
So use with caution or at your own risk. We are not responsible for any thing. Thank You!
Download Code Link is at the end of the post.
BJ Image Cropper:
BJ Image Cropper is very simple UIVIEW perhaps user friendly that allows user to do cropping, using a cropper which is displayed over an image, and you can drag cropper over image areas and can crop.For this you will need already build .h and .m file which i will provide including whole application. You can get this application by reading above note.
Reference Link
How this application Works ? :
The Reason for explaining this non-technical part is to let people understand the flow of the program.
Now Again.
Touch Select button => Image loaded into UIIMAGEVIEW
Touch Crop button => Image from UIIMAGEVIEW is loaded into UIVIEW and a Cropper is appeared on that UIVIEW which is able to drag.
Touch Apply Crop Button => Cropped Image from the UIVIEW is Loaded into UIIMAGE *Image and then into UIIMAGEVIEW = image ;
Now here Comes the Code:
Download Link:
BJ Image Cropper:
BJ Image Cropper is very simple UIVIEW perhaps user friendly that allows user to do cropping, using a cropper which is displayed over an image, and you can drag cropper over image areas and can crop.For this you will need already build .h and .m file which i will provide including whole application. You can get this application by reading above note.
Reference Link
How this application Works ? :
- When this application start running you will need to select a photo from camera roll and then image is loaded into the UIIMAGEVIEW.
- After this You will need to press the button Crop when you Touch, a cropper will appear on subview of image and then you have to select your cropping area by touching the ends of rectangle appearing in that Subview.
- After this You have to touch another button which takes crop image into a Dummy Variable of type UIIMAGE and then you have to put that Dummy variable into the UIIMAGEVIEW.
The Reason for explaining this non-technical part is to let people understand the flow of the program.
Now Again.
Touch Select button => Image loaded into UIIMAGEVIEW
Touch Crop button => Image from UIIMAGEVIEW is loaded into UIVIEW and a Cropper is appeared on that UIVIEW which is able to drag.
Touch Apply Crop Button => Cropped Image from the UIVIEW is Loaded into UIIMAGE *Image and then into UIIMAGEVIEW = image ;
Now here Comes the Code:
- This is update is Used to update the gui mask or rectangle which is on UIVIEW.
- Size of this Rectangle can also be changed by holding clicks at the ends of rectangle corners.
- In this function if origin is changed then a new origin with same height and width is update
- If height and width is changed then a new height and width is update.
- Both above task can be done simultaneously.
- This function uses BJIMAGECropper.h and BjimageCropper.m which will be provided if you need just comment.
![]() |
UIVIEW |
- (void)updateDisplay {
self.boundsText.text = [NSString stringWithFormat:@"(%f, %f) (%f, %f)", CGOriginX(self.imageCropper.crop), CGOriginY(self.imageCropper.crop), CGWidth(self.imageCropper.crop), CGHeight(self.imageCropper.crop)];
if (SHOW_PREVIEW) {
self.preview.image = [self.imageCropper getCroppedImage];
self.preview.frame = CGRectMake(10,10,self.imageCropper.crop.size.width * 0.1, self.imageCropper.crop.size.height * 0.1);
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([object isEqual:self.imageCropper] && [keyPath isEqualToString:@"crop"]) {
[self updateDisplay];
}
}
-(void) viewWillAppear:(BOOL)animated{
// No need to store… this is 1 use only anyway. Save memory, and release it when done.
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsEditing = NO;
self.imgPicker.delegate = self;
}
- This function crops the image this function takes coordinates of mask or rectangle from gui and subtract all pixels from that location to end corners.
![]() |
Crop |
-(IBAction)getcorp:(id)sender{
initWithFrame:CGRectMake(10,10,self.imageCropper.crop.size.width * 0.1, self.imageCropper.crop.size.height * 0.1)];
UIImage *im = [self.imageCropper getCroppedImage];
self.image_view.image = im;
for(UIView *sub in [self.view subviews])
{
if([sub isKindOfClass:[imageCropper class]])
[sub removeFromSuperview];
}
}
- This function creates a subview and extract image from UIImageView and creates a mask or rect on that image which is displayed on UIVIEW.
- Means it creates a cropper on that gui UIVIEW where you image is displayed.
![]() |
Subview |
-(IBAction)corp:(id)sender{
CGFloat height = image_view.bounds.size.height;
CGFloat width = image_view.bounds.size.width;
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tactile_noise.png"]];
self.imageCropper = [[BJImageCropper alloc] initWithImage:img andMaxSize:CGSizeMake(height,width) ];
[self.view addSubview:self.imageCropper];
self.imageCropper.center = self.view.center;
self.imageCropper.imageView.layer.shadowColor = [[UIColor blackColor] CGColor];
self.imageCropper.imageView.layer.shadowRadius = 3.0f;
self.imageCropper.imageView.layer.shadowOpacity = 0.8f;
self.imageCropper.imageView.layer.shadowOffset = CGSizeMake(1, 1);
[self.imageCropper addObserver:self forKeyPath:@"crop" options:NSKeyValueObservingOptionNew context:nil];
if (SHOW_PREVIEW) {
self.preview = [[UIImageView alloc] initWithFrame:CGRectMake(10,10,self.imageCropper.crop.size.width * 0.1, self.imageCropper.crop.size.height * 0.1)];
self.preview.image = [self.imageCropper getCroppedImage];
self.preview.clipsToBounds = YES;
self.preview.layer.borderColor = [[UIColor whiteColor] CGColor];
self.preview.layer.borderWidth = 2.0;
[self.view addSubview:self.preview];
}
}
- This function accesses camera roll.
![]() |
Camera Roll |
-(IBAction)next:(id)sender{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:self.imgPicker animated:YES];
}
- When Image is picked picker should be dismissed.
-(void)imagePickerControllerDidCancelUIImagePickerController *)picker{
[picker dismissModalViewControllerAnimated:YES];
}
- Picks image from from camera roll.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {[picker dismissModalViewControllerAnimated:YES];img = [info objectForKey:@"UIImagePickerControllerOriginalImage"];self.image_view.image=img;}
- This the variable mask which is created on that gui UIView.
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {CGImageRef maskRef = maskImage.CGImage;CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),CGImageGetHeight(maskRef),CGImageGetBitsPerComponent(maskRef),CGImageGetBitsPerPixel(maskRef),CGImageGetBytesPerRow(maskRef),CGImageGetDataProvider(maskRef), NULL, false);CGImageRef masked = CGImageCreateWithMask([image CGImage], mask);return [UIImage imageWithCGImage:masked];}- (void)viewDidUnload{[super viewDidUnload];[self setImageCropper:nil]; //image croper[self setBoundsText:nil]; // image croper[self.imgPicker release]; // Release this here, this will execute when modal view is popped.}- (void)viewDidUnload{[super viewDidUnload];[self setImageCropper:nil]; //image croper[self setBoundsText:nil]; // image croper[self.imgPicker release]; // Release this here, this will execute when modal view is popped.// Release any retained subviews of the main view.// e.g. self.myOutlet = nil;}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{// Return YES for supported orientationsreturn (interfaceOrientation == UIInterfaceOrientationPortrait);}
Download Link: