首页 \ 问答 \ 制作所需的图像字段(Make an image field required)

制作所需的图像字段(Make an image field required)

我正在尝试在wordpress中进行图片上传所需的输入。 这个想法是上传一个图像,然后裁剪,然后保存。 但是,由于输入标签会发生变化(您可以看到2个输入,一个是上传之前,另一个是之后),它们变成了“隐藏”的样式,这使得代码不可聚焦并引发错误。

  <fieldset <?php if ($current_user->roles[0] == "contributor") {
                        # code...
                        echo "disabled";
                      } ?>>



                      <label for="postImage"><?php esc_html_e('ID Picture *:', ''); ?></label>

                        <?php esc_html_e('Image needs to be at least 250x250px', '');?>

                        <?php $baseurl = get_template_directory_uri().'/include/'; ?>

                         <div id="flash"></div>
                          <div id="ajaxresult">


                          </div>
                          <div id="files">
                          <?php
                          $photo_user = get_user_meta(get_current_user_id(), 'id_pic', true);?>
                          <?php
                          if (isset($photo_user)) {
                             echo "<img src='".esc_url($photo_user)."' id='uploadedimage' style='width:100%'>";
                          }  ?>
                         </div>
                        <span id="me" class="styleall button-small fileinput-button" style=" cursor:pointer;" >

                            <?php if(isset($photo_user)) {
                          esc_html_e('Click Here To Upload New Photo', '');
                        } else {
                          esc_html_e('Click Here To Upload Photo', '');
                        }
                        ?><input id="meimg" type="file" name="files[]" >

                        </span>


                        <div id="load"></div><span id="mestatus" ></span>


                        <div id="status"></div>
                        <div id="cropme" style="display:none;"><a class="button-small crop-me"><?php esc_html_e('CROP IMAGE', ''); ?></a></div>

                        <div id="cancelme0" style="display:none;"><a class="button-small"><?php esc_html_e('cancel', ''); ?></a></div>


                        <div id="cancelme" style="display:none;"><a class="button-small"><?php esc_html_e('cancel', 'fundingpress'); ?></a></div>
                                <br>
                             <input type="hidden" name="postImage" id="postImage" value="" />

                            </fieldset>

I am trying to make an input required for an image upload in wordpress. The idea is to upload an image, then crop it, and save. However, since the input tags change (you can see 2 inputs, one before uploading and one after), they become style "hidden", which makes the code not focusable and throws an error.

  <fieldset <?php if ($current_user->roles[0] == "contributor") {
                        # code...
                        echo "disabled";
                      } ?>>



                      <label for="postImage"><?php esc_html_e('ID Picture *:', ''); ?></label>

                        <?php esc_html_e('Image needs to be at least 250x250px', '');?>

                        <?php $baseurl = get_template_directory_uri().'/include/'; ?>

                         <div id="flash"></div>
                          <div id="ajaxresult">


                          </div>
                          <div id="files">
                          <?php
                          $photo_user = get_user_meta(get_current_user_id(), 'id_pic', true);?>
                          <?php
                          if (isset($photo_user)) {
                             echo "<img src='".esc_url($photo_user)."' id='uploadedimage' style='width:100%'>";
                          }  ?>
                         </div>
                        <span id="me" class="styleall button-small fileinput-button" style=" cursor:pointer;" >

                            <?php if(isset($photo_user)) {
                          esc_html_e('Click Here To Upload New Photo', '');
                        } else {
                          esc_html_e('Click Here To Upload Photo', '');
                        }
                        ?><input id="meimg" type="file" name="files[]" >

                        </span>


                        <div id="load"></div><span id="mestatus" ></span>


                        <div id="status"></div>
                        <div id="cropme" style="display:none;"><a class="button-small crop-me"><?php esc_html_e('CROP IMAGE', ''); ?></a></div>

                        <div id="cancelme0" style="display:none;"><a class="button-small"><?php esc_html_e('cancel', ''); ?></a></div>


                        <div id="cancelme" style="display:none;"><a class="button-small"><?php esc_html_e('cancel', 'fundingpress'); ?></a></div>
                                <br>
                             <input type="hidden" name="postImage" id="postImage" value="" />

                            </fieldset>

原文:https://stackoverflow.com/questions/45423494
更新时间:2023-06-02 15:06

最满意答案

“lug The”一词来自报纸生产的世界。

在生产过程中,这是一个非正式的名称。 由于这个故事从节拍记者那里走过(假设这些甚至还存在 ),通过编辑到“印刷机”,这就是它所引用的名字,例如“你在”凯特威廉的故事?

一些系统(如Django)使用slug作为URL的一部分来定位故事,一个例子是www.mysite.com/archives/kate-and-william

它甚至可能早于之前,因为剧本在每个场景开始时都有“lug lug线”,这基本上设置了那个场景的背景(在哪里,何时,等等)。 这是非常相似的,因为它是以下的准则或前言。

在Linotype机器上,一个s子是一个单一的金属片,它是从单独的信件形成的。 通过为整行制作一个单一的插件,这在旧的逐字符合成中大大改善。

虽然以下是猜想,但是lug an的早期意思是伪造的硬币(必须按某种方式按压)。 我可以设想将这种使用转变为印刷术语(因为必须使用原始字符压制s子),并从那里改变从“金属”定义到“故事摘要”的定义。 从那里,这是从正确的打印到在线世界的一小步。


The term 'slug' comes from the world of newspaper production.

It's an informal name given to a story during the production process. As the story winds its path from the beat reporter (assuming these even exist any more?) through to editor through to the "printing presses", this is the name it is referenced by, e.g., "Have you fixed those errors in the 'kate-and-william' story?".

Some systems (such as Django) use the slug as part of the URL to locate the story, an example being www.mysite.com/archives/kate-and-william. Even Stack Overflow does this, with the GEB-ish self-referential https://stackoverflow.com/questions/4230846/what-is-the-etymology-of-slug/4230937#4230937, although you can replace the slug with blahblah and it will still find it okay.

It may even date back earlier than that, since screenplays had "slug lines" at the start of each scene, which basically sets the background for that scene (where, when, and so on). It's very similar in that it's a precis or preamble of what follows.

On a Linotype machine, a slug was a single line piece of metal which was created from the individual letter forms. By making a single slug for the whole line, this greatly improved on the old character-by-character compositing.

Although the following is pure conjecture, an early meaning of slug was for a counterfeit coin (which would have to be pressed somehow). I could envisage that usage being transformed to the printing term (since the slug had to be pressed using the original characters) and from there, changing from the 'piece of metal' definition to the 'story summary' definition. From there, it's a short step from proper printing to the online world.

相关问答

更多
  • 1:如果有301的话,我认为没有必要使用规范标签。 让我们想象一下你将URL从/q/111/hello-world更改为/q/111/foobar的场景。 引擎不会假设两者是平等的,除非他们访问原始URL并在其上指向/q/111/foobar的规范标签(它不会,因为它现在是301,切断页面之间关系的任何证据)。 2:我会直接做这件事。 定义一个非唯一的slug字段,并与详细信息视图中的捕获网址进行比较。 # models class MyModel(models.Model): # ... ...
  • s s s sㄧs。。。。。。。。。。。。。。。。。。 诸如Google的搜索引擎,如果搜索字在URL中,则将页面排列更高。 The slugs make the URL more user-friendly and you know what to expect when you click a link. Search engines such as Google, rank the pages higher if the searchword is in the URL.
  • slug为页面提供了一个人性化的url片段。 当人们决定是否点击链接时,这通常很有用。 例如,在此页面的网址中有一个: http://stackoverflow.com/questions/6192655/whats-the-advantage-or-benefit-of-slug-field-in-django 实际上,您可以在没有slug的情况下(在StackOverflow的系统中)得到这个问题,但是slug是一种更友好,更有语义的方式来处理页面。 搜索引擎确实会对页面地址中出现的单词产生一定的影响。 ...
  • “lug The”一词来自报纸生产的世界。 在生产过程中,这是一个非正式的名称。 由于这个故事从节拍记者那里走过(假设这些甚至还存在 ),通过编辑到“印刷机”,这就是它所引用的名字,例如“你在”凯特威廉的故事? 一些系统(如Django)使用slug作为URL的一部分来定位故事,一个例子是www.mysite.com/archives/kate-and-william 。 它甚至可能早于之前,因为剧本在每个场景开始时都有“lug lug线”,这基本上设置了那个场景的背景(在哪里,何时,等等)。 这是非常相似 ...
  • 这是一种生成有效网址的方法,通常使用已获得的数据。 例如,使用文章的标题来生成URL。 我建议使用功能,给出标题(或其他数据),而不是手动设置,生成s。。 一个例子: The 46 Year Old Virgin A silly comedy movie the-46-year-old-virgin 现在假设我们有一个Django模型,如: class Article(models.Model): ...
  • 不知道你的模型定义如何,但如果你有连接Faculty , Department等的外键,你可以一直导航: query_list = Course.objects.filter(programme__department__faculty__slug=faculty_slug) 或者,由于您拥有教师实例: qr = get_object_or_404(Faculty, faculty_slug=faculty_slug) query_list = Course.objects.filter(programm ...
  • 正如您所提到的, push和pop是堆栈操作的通用名称。 它不仅仅是push和pop的原因是它可以与其他容器保持一致。 std::vector只实现了push_back和pop_back ,但是还有push_front和pop_front ,例如std::list 。 编写通用函数时,具有一致的名称很有用。 As you mention, push and pop are common names for stack operations. The reason it's not just push and ...
  • 我最终使用This Django Snippet来覆盖我的models.py中的Phone的保存方法: def save(self, **kwargs): slug_str = "%s %s %s %s" % (self.user, self.year, self.model, self.series) unique_slugify(self, slug_str) super(Phone, self).save() 但感谢jpic的贡献。 I ended up using This ...
  • 一般来说,我用它来产生一个友好的网址 。 如果您愿意,可以在URL中使用它是人类可读的ID。 我认为这也是SEO友好的。 你可以这样使用: mysite.com/products/xbox360-fifa-15 代替 mysite.com/products/123456 在你的链接中,如果slug已经存在,该方法将生成: mysite.com/products/xbox360-fifa-15-1 性能:不要忘记在您使用的每个slug列上创建索引。 In general, I use it to gen ...
  • 作为items = items.filter((item)的结果,您通过重新定义items来覆盖原始数组。 你也在搜索tag.title而不是tag.value ; items.tags数组没有一个对象元素,其中的一个属性在javascript处于"tilte"问题。 使用.some()代替.map() ; .map()返回一个新数组, .some()返回一个Boolean 。 items = [ { "slug":"foo", "tags":[ {"value" ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)