In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "realization of picture seo method sharing", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "to achieve picture seo method sharing" bar!
First, we create a database table to hold our picture information and the corresponding src.
The code is as follows:
$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb- > prefix} seo_ image` (
`ID`bigint (20) unsigned NOT NULL AUTO_INCREMENT
`image_ name` char (250) NOT NULL
`image_ type` text NOT NULL
`image_ src` longtext NOT NULL
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; "
$wpdb- > query ($sql)
This data sheet is used to hold all the pictures we want to process. (note that there are several kinds of pictures that we don't need to deal with: pictures of this site, pictures accessed by non-http addresses.)
Second, we need to have some functions that deal with the database, which we write by ourselves. These functions are used to complete the insert, query, modify, delete and other operations that we want to deal with.
Next, we need an image processing function image ($src), which converts the original address of the picture, outputs it to a SEO address, and can be accessed again. I do this in my program:
The code is as follows:
Function image ($src) {
Global $slipForImg
If (strpos ($src,'http')! = = 0) return $src
If (strpos ($src,'http') = = 0 & & strpos ($src,get_bloginfo ('url')) = = 0) return $src
$imageinfo = pathinfo ($src)
$image_ext = $imageinfo ['extension']
If (
Strpos ($image_ext,'jpg')! = = 0
& & strpos ($image_ext,'jpeg')! = = 0
& & strpos ($image_ext,'gif')! = = 0
& & strpos ($image_ext,'png')! = = 0
) return $src
$image = create_image ($src)
Return get_bloginfo ('url'). "/ {$slipForImg} /". $image- > image_name.'.'.$image- > ID.'.'.$image- > image_type
}
There is a create_image () function in the above function, which is the function that works with the database mentioned in the previous step. I also created another function img ($src) = function () {echo image ($src);} to print the SEO address. If we need to use a picture in the theme, we can use the following code to do so:
The code is as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.