Keyword

k2 to com_content Issue

  • Syed Raza Naqvi
  • Syed Raza Naqvi's Avatar Topic Author
  • Offline
  • New Member
More
6 years 1 week ago #167430 by Syed Raza Naqvi
k2 to com_content Issue was created by Syed Raza Naqvi
hi

I have more than 32,000 items , problem is when I started web site I have changed k2 core how image was renamed with watermark.

I used below code to save images without md5:
$handle->file_new_name_body = $row->alias.$row->id;
.md5("Image".$row->id).  change to .$row->alias.$row->id.
md5("Image".$current->id) change to .$row->alias.$row->id.
.md5("Image".$item->id).  change to .$row->alias.$row->id.
.md5("Image".$news_id).  change to .$row->alias.$row->id.

Now I am migrating to WordPress and when converting items to content....Images can not be transferred to content even FG joomla is unable to import k2 images, and JA plugin k2 to content migration plugin also failed. in plugin I am using following code;
/**
		 * Get the featured image
		 * 
		 * @param int $item_id Item ID
		 * @return string Image name
		 */
		private function get_featured_image($item_id) {
			$found_image_name = '';
			[b]$image_md5 = ("p.alias" . $item_id);[/b]
			
			// Try to get the original image in the src folder
			$image_name = 'media/k2/items/src/' . $image_md5 . '.jpg';
			$image_url = trailingslashit($this->plugin->plugin_options['url']) . $image_name;
			if ( $this->plugin->url_exists($image_url) ) {
				$found_image_name = $image_name;
			} else {
				
				// if the featured image doesn't exist in the src folder, try to get the XL image in the cache folder
				$image_name = 'media/k2/items/cache/' . $image_md5 . '_XL.jpg';
				$image_url = trailingslashit($this->plugin->plugin_options['url']) . $image_name;
				if ( $this->plugin->url_exists($image_url) ) {
					$found_image_name = $image_name;
				}
			}
			return $found_image_name;
		}

or
private function _convertK2Items($batch = 50) {
		$k2items = $this->fetchItems($batch); // select items with cat and extra fields condition.
		$numItems = count($k2items);
		if (!$numItems) {
			return 0;
		}
		$qi_q = 'INSERT INTO #__content_meta (id, content_id, meta_key, meta_value , encoded) VALUES ';
		$qi_v = array();
		$count=0;

		foreach ($k2items AS $k => $v) {
			$tags = array();
			$assoc = $this->checkAssociation($v->id, 'item');
			if (!$assoc) {
				// Copy Image from K2.
				if (JFile::exists(JPATH_ROOT . '/media/k2/items/src/' . 'alias' . $v->id . '.jpg')) {
					JFolder::create(JPATH_ROOT . '/images/joomlart/article/'); // create recusive folder.
					copy('../media/k2/items/src/' . 'alias' . $v->id . '.jpg', '../images/joomlart/article/' . 'alias' . $v->id . '.jpg');
					$images = array(
						'image_intro' => 'images/joomlart/article/' . 'alias' . $v->id . '.jpg',
						'float_intro' => '',
						'image_intro_alt' => $v->image_caption,
						'image_intro_caption' => $v->image_credits,
						'image_fulltext' => 'images/joomlart/article/' . 'alias' . $v->id . '.jpg',
						'float_fulltext' => '',
						'image_fulltext_alt' => $v->image_caption,
						'image_fulltext_caption' => $v->image_credits
					);
					$images = json_encode($images);
				} else
					$images = '';

				// Convert Tag id from k2 to new id.
				if ($v->tags_id != NULL) {
					$tags_id = explode(',', $v->tags_id);
					foreach ($tags_id AS $tg) {
						$tag = $this->checkAssociation($tg, 'tag');
						if($tag) {
							$tags[] = $tag->key;
						}
					}
				}
please tell me how can i force plugin to find images with naming alias.itemid.jpg.....please

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum